0

Possible Duplicate:
Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser

I am working to replace an old vb6 app with a web app. in the old app the save button was linked to f8 and the users of this application want that to stay the same. How can i capture the f8 button so that it is linked to my save button? Thanks

Community
  • 1
  • 1
chris
  • 65
  • 4
  • 11

2 Answers2

1

YOu should be able to bind to the 'keyup' event and look at the keyCode. Here is a list of the keycodes you will need.

http://www.cambiaresearch.com/c4/702b8cd1-e5b0-42e6-83ac-25f0306e3e25/javascript-char-codes-key-codes.aspx

0

DOM_VK_F8 = 119, so you should check to see that the keypress event listener's event object's keyCode property is equal to 119.

addEventListener('keypress', function(e) {
    if (e.keyCode == 119)
        ; // do stuff here
}, false);
Delan Azabani
  • 79,602
  • 28
  • 170
  • 210