javascript - addEventListener keyup Keydown with Keycode not working -
this.element.addeventlistener('keydown', function(e) { if ((e.keycode || e.which) == 32) { self.space_down(e); } }, true); this.element.addeventlistener('keyup', function(e) { if ((e.keycode || e.which) == 32) { self.space_up(e); } }, true);
this not working, why?, iv'e similar code watch mouse events , works fine, there solution?
try bind event document
or window
. if element not focusable , not focused, keyboard events won't dispatch it, instead dispatch document root(<body>
).
Comments
Post a Comment