indications.js 794 B

1234567891011121314151617181920212223242526
  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 experimentId = document.getElementsByName('experimentId')[0].value
  16. const params = `?scene=${scene}&expe=${expe}&experimentId=${experimentId}&iteration=0`
  17. console.log(expeUrl + params)
  18. window.location = expeUrl + params
  19. }
  20. }
  21. // implement `key` events
  22. document.addEventListener('keydown', checkKey)