按空格键向下移动页面? [英] Pressing spacebar moves page down?

查看:323
本文介绍了按空格键向下移动页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我甚至不确定要搜索以修复。当我按空格键我的整个页面向下移动:我不想这种情况发生。我的 body 标记样式为 overflow:hidden ,如果这与它有关, t有任何滚动条。我通常相当擅长执行初步的故障排除技术,但在这种情况下,我甚至不知道从哪里开始。如何停止此行为?

I have a problem that I'm not even sure what to search for in order to fix. When I press the spacebar my entire page moves down: I don't want this to happen. My body tag is styled to overflow:hidden, if that has anything to do with it, so the page won't have any scrollbars. I'm usually pretty good at executing the preliminary troubleshooting techniques but in this case I don't even know where to start. How can I stop this behaviour?

其他信息:我正在使用jQuery 1.4.2

Additional information: I am using jQuery 1.4.2

推荐答案

除非你使用按键,这是大多数浏览器的预期行为。

Unless you eat the keypress this is the expected behavior in most browsers. I use it all the time and I get extremely annoyed when it doesn't work in a page.

但是如果你想吃这个钥匙...

But if you want to eat the key...

window.onkeydown = function(e) { 
  return !(e.keyCode == 32);
};

这篇关于按空格键向下移动页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆