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

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -