keyboard.js 372 B

12345678910111213141516171819
  1. import EventSystem from './EventSystem';
  2. export default class Keyboard extends EventSystem{
  3. constructor(){
  4. super()
  5. this.keys = {};
  6. // window.addEventListener('onkeypress', (e) => this.press(pliktro) )
  7. }
  8. listen() {
  9. window.addEventListener('keydown',(e) => {
  10. //TODO add functionality
  11. this.emit(e.key);
  12. this.emit(e.keyCode);
  13. });
  14. return this;
  15. }
  16. }