Disable Scrolling With Arrow Keys in Flash

一个人想着一个人 提交于 2020-01-05 09:02:46

问题


I have a flash embed code in my webpage. When playing the game, page is scrolling with Up and Down keys. How can i prevent this? Firefox is ok, but it's only scrolling in IE.


回答1:


A jQuery way of handling this:

$(document).bind('keydown keypress', function(e) {
    if(e.keyCode > 36 && e.keyCode < 41) e.preventDefault();
});

The page scrolls when the arrow keys (key 37-40) are hit (keydown) and when they're kept down (keypress). So, if this happens we prevent the default event by e.preventDefault();



来源:https://stackoverflow.com/questions/5446069/disable-scrolling-with-arrow-keys-in-flash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!