开发者

javascript: capturing function (f1-12) keys [duplicate]

开发者 https://www.devze.com 2023-03-25 12:52 出处:网络
This questio开发者_开发问答n already has answers here: Closed 11 years ago. Possible Duplicate: Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser
This questio开发者_开发问答n already has answers here: Closed 11 years ago.

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


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


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号