简体   繁体   中英

F8 and F9 keys not being captured in Chrome with jQuery

I want to use some function keys as shortcuts to my web app. Everything seems to work, except that I can't capture F8 and F9 on chrome. I'm using jQuery 2.1, and am registering to the keydown event with:

$(window).on('keydown', function(e) {
    ...
};

I have made a very simple JsFiddle to illustrate the problem. If I press any key, the text in the div is updated. Nothing happens if I press F8 or F9. I have tested on Firefox and it works, so it's a browser specific problem, even maybe some configuration in my machine.

My chrome's version is 37.0.2062.120 m

Another weird thing is that if I press F8 or F9 along with some modifier key (alt, shift or control), it works.

Anyone have any ideas?

I have solved my problem.

I was running Chrome with the flag --disable-web-security, to allow CORS requests while in development. I restarted Chrome without the flag and everything started working.

Have no idea why, but will leave this here... maybe will help someone in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM