我试图从一个对象中获取一个值并在屏幕上显示但是没有成功......
http://jsfiddle.net/Lbascg4v/5/
has_secure_password
validates :password, presence: true, length: { minimum: 6 }, allow_nil: true
当我在画布上按下一个键时,我想获取我的键的值并放入我的对象,然后我想打印该对象及其值。
答案 0 :(得分:0)
您问题的真正答案很可能您不需要原型设计:
function KeyDown(){
// Initialize properties
this.faq = 0;
this.update = function(e){
// Set faq
this.faq = e.keyCode;
}
this.print = function(){
// Alert faq
alert(this.faq);
}
}
然后:
窗口。
test = new KeyDown();
addEventListener('keydown', test.update, true);
test.print(); // Will alert 0