我试图在输入按键检测事件处理程序中传递对象原型函数调用,但不知道如何去做。任何帮助将不胜感激代码如下:
function foo{};
foo.prototype.shout = function() {
alert(shout);
}
foo.prototype.someOtherFunction = function (event) {
var e = event || window.event,
code = e.charCode || e.keyCode;
if(code === 38) {
foo.shout// This is what doesn't work - sorry for the confusion
}
}
foo.prototype.applyKeypress = function (_input) {
var self = this;
_input.onkeypress = foo.someOtherFunction; // someOtherFunction applied here
}