indications.js 682 B

12345678910111213141516171819202122232425
  1. // Utils informations
  2. const KEYCODE_Q = 81
  3. const KEYCODE_ENTER = 13
  4. urlParams = new URLSearchParams(window.location.search)
  5. const scene = urlParams.get('scene')
  6. const expe = urlParams.get('expe')
  7. const checkKey = e => {
  8. if (e.keyCode === KEYCODE_Q) {
  9. // `q` to quit expe
  10. console.log('`q` key is pressed')
  11. window.location = ''
  12. }
  13. else if (e.keyCode === KEYCODE_ENTER) {
  14. // right arrow
  15. const params = `?scene=${scene}&expe=${expe}&iteration=0`
  16. console.log(expeUrl + params)
  17. window.location = expeUrl + params
  18. }
  19. }
  20. // implement `key` events
  21. document.addEventListener('keydown', checkKey)