1 Replies - 1211 Views - Last Post: 24 December 2010 - 09:45 AM

#1 devangnegandhi  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 40
  • Joined: 23-January 06

Key Event Listener

Posted 13 September 2007 - 08:10 AM

Description: place this part of code in the sectionAn event listener to listen on any keys pressed
windows.onload=function()
{
     document.onkeydown = key_event;
     document.onkeypress = key_event;
}
function key_event(evt)
{
     //write any code here that you want 
     //to perform when a key is pressed.

     //here is one example for de-activating the 'esc'

     if(e.keyCode == 27) return false; //keyCode returns the ASCII value of the key pressed.
}


Is This A Good Question/Topic? 0
  • +

Replies To: Key Event Listener

#2 elisamuel40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 24-December 10

Re: Key Event Listener

Posted 24 December 2010 - 09:45 AM

On line 1 there's an error it should be: window.onload=function() *(window, not windows)*
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1