faqts : Computers : Programming : Languages : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

96 of 106 people (91%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Can I capture the Delete key?

Jan 27th, 2007 03:04
Steve White, Martin Honnen,


All browsers are different on this point.  In some cases it's not possible.
Opera 9.1 -- no keyPress.  keyDown 46.
         unfortunately, indistinguishable from the "." key event.
Konqueror keyCode 127 (ASCII DEL) keyPress: event.charCode=0, which=127 
          also keyDown
NN6 is leading here as it fires onkeydown, onkeypress, and onkeyup for 
the delete key. You can check
  event.which == 46
to find that key.
IE5 is firing onkeydown and onkeyup but not onkeypress for the delete 
key. You can check
  event.keyCode == 46
to find the key.
Finally NN4 seems to fire only onkeyup for the delete key but 
unfortunately 
  event.which
is 0 in that case which makes it impossible to recognize the key.