keyEvents.js 460 B

12345678910111213141516171819202122
  1. // implement `key` events
  2. document.onkeydown = checkKey;
  3. function checkKey(e) {
  4. e = e || window.event;
  5. if (e.keyCode == '81') {
  6. // `q` for quit expe
  7. console.log('`q` key is pressed');
  8. window.location = ''
  9. }
  10. else if (e.keyCode == '37') {
  11. // left arrow
  12. console.log('left arrow is pressed');
  13. }
  14. else if (e.keyCode == '39') {
  15. // right arrow
  16. console.log('right arrow is pressed');
  17. }
  18. }