cel*_*owm 1 javascript events keypress prototypejs
我需要在原型上操纵"左"和"右"键,例如http://mangastream.com/
很简单:
$(document).observe('keydown', function (e) {
switch (e.keyCode) {
case Event.KEY_LEFT:
e.stop(); // prevent the default action, like horizontal scroll
window.location = '/read/prev';
break;
case Event.KEY_RIGHT:
e.stop();
window.location = '/read/next';
break;
}
});
Run Code Online (Sandbox Code Playgroud)
Event.KEY_LEFT并且Event.KEY_RIGHT是它们对应键的数字代码的便利常量.
阅读http://api.prototypejs.org/dom/Event/上的Prototype事件.
| 归档时间: |
|
| 查看次数: |
864 次 |
| 最近记录: |