慕姐8265434
event.keyBlink(Chrome)不像其他引擎(浏览器)那样理解。也不要使用该keypress事件,它不太可靠(无法立即回忆起原因),但请确保在实际环境中使用代码之前对其进行测试。function event_key(){ var r = false; if (Object.defineProperty) { Object.defineProperty(KeyboardEvent.prototype,'key', { get:function () { var r; var k = {'65':'a','66':'b','67':'c','68':'d','69':'e','70':'f','71':'g','72':'h','73':'i','74':'j','75':'k','76':'l','77':'m','78':'n','79':'o','80':'p','81':'q','82':'r','83':'s','84':'t','85':'u','86':'v','87':'w','88':'x','89':'y','90':'z','8':'Backspace','9':'Tab','13':'Enter','16':'Shift','17':'Control','18':'Alt','20':'CapsLock','27':'Esc','32':' ','33':'PageUp','34':'PageDown','35':'End','36':'Home','37':'Left','38':'Up','39':'Right','40':'Down','45':'Insert','46':'Del','48':'0','49':'1','50':'2','51':'3','52':'4','53':'5','54':'6','55':'7','56':'8','57':'9','91':'OS','92':'OS','93':'Menu','96':'0','97':'1','98':'2','99':'3','100':'4','101':'5','102':'6','103':'7','104':'8','105':'9','106':'*','107':'+','109':'-','110':'.','111':'/','112':'F1','113':'F2','114':'F3','115':'F4','116':'F5','117':'F6','118':'F7','119':'F8','120':'F9','121':'F10','122':'F11','123':'F12','144':'NumLock','145':'ScrollLock','186':':','187':'=','188':',','189':'-','190':'.','191':'/','192':'`','219':'[','220':'\\','221':']','222':'\''} if (k[this.keyCode]) {r = k[this.keyCode];} else {r = 'Unknown Key';} return r; } }); } return r;}window.onkeydown = function(event){ var k = (event.key) ? event.key : event_key(); console.log('Key pressed: '+k);}