javascript - Firefox makes weird things on event modification -


i've done little keydown event modification 2d 'framework'.

window.addeventlistener('keydown', function(e) {     e = e || window.event;      e.key = that.keycodetokeyname[e.keycode];      fireevent('keydown', e); }); 

where that.keycodetokeyname is

that.keycodetokeyname = {8: 'backspace', 9: 'tab', 13: 'enter', 16: 'shift', 17: 'ctrl', 18: 'alt', 19: 'pause', 20: 'capslock', 27: 'esc', 32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down', 45: 'insert', 46: 'delete', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', 54: '6', 55: '7', 56: '8', 57: '9', 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', 96: 'numpad0', 97: 'numpad1', 98: 'numpad2', 99: 'numpad3', 100: 'numpad4', 101: 'numpad5', 102: 'numpad6', 103: 'numpad7', 104: 'numpad8', 105: 'numpad9', 112: 'f1', 113: 'f2', 114: 'f3', 115: 'f4', 116: 'f5', 117: 'f6', 118: 'f7', 119: 'f8', 120: 'f9', 121: 'f10', 122: 'f11', 123: 'f12'}; 

so if i, in chrome, call

_.on('keydown', function(e) {            if (e.key === 'space' && paused)         return newround();      keys[e.key] = true; }); 

e.key is, example 'left', 'ctrl', 'n', ...

but in firefox first letter of string uppercase ?! has idea why happens ?

i tried getting key-name in own listener function:

_.on('keydown', function(e) {     var key = _.keycodetokeyname[e.keycode];      if (key === 'space' && paused)         return newround();      keys[key] = true; }); 

which works in both browsers.

this because event.key valid property in firefox. pass key-string around functions argument or use property name


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -