javascript - 原型(prototype)(Javascript): How do I observe multiple events for the same element?

标签 javascript prototypejs

Veeery 基本问题,但我无法找到一个简单的答案(而且我不知道我在做什么,目前没有时间正确学习 javascript 或原型(prototype) :-/)。

我正在尝试重新使用 this bit of code它甚至可以完全按照我的意愿行事 ;),只是我不知道如何更改这部分:

function init() {

    Event.observe(document.body, 'mousemove', resetIdle, true);

    setIdle();

}

我希望它不仅能观察“mousemove”,还能同时观察“keydown”。我该怎么做?

最佳答案

function init() {

    Event.observe(document.body, 'mousemove', resetIdle, true);
    Event.observe(document.body, 'keydown', resetIdle, true);

    setIdle();

}

很明显,不是吗?

关于javascript - 原型(prototype)(Javascript): How do I observe multiple events for the same element?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5050839/

相关文章:

javascript - 使用 jQuery 创建元素

javascript - WinJS 导航模板 + ListView

javascript - 原型(prototype)中相邻函数的问题

javascript - 如何使用原型(prototype)中的类获取输入值?

javascript - 原型(prototype): how to get new input value after some key pressed?

javascript - 整个网站使用 Lightbox

javascript - Meteor event.target.files 未定义?

javascript - 将所有元素替换为另一个 jquery

javascript - 如何打印所有选中的复选框?

Prototype 中 JQuery 的 getScript 等效项