1234567891011121314151617181920212223242526272829 |
- // implement `key` events
- document.onkeydown = checkKey;
- function checkKey(e) {
- e = e || window.event;
- if (e.keyCode == '81') {
- // `q` for quit expe
- console.log('`q` key is pressed');
- window.location = ''
- }
- else if (e.keyCode == '37') {
- // left arrow
- console.log('left arrow is pressed');
- }
- else if (e.keyCode == '39') {
- // right arrow
- console.log('right arrow is pressed');
- }
- else if (e.keyCode == '13') {
- // right arrow
- // TODO : avoid refresh with `enter` key when it is not necessary
- console.log('right arrow is pressed');
- window.location = window.location.href
- }
- }
|