indications.js 772 B

1234567891011121314151617181920212223242526272829303132
  1. // implement `key` events
  2. document.onkeydown = checkKey;
  3. var host = window.location.host
  4. var expe_url = '/expe'
  5. var baseUrl = location.protocol + "//" + host
  6. // Utils informations
  7. var KEYCODE_Q = '81'
  8. var KEYCODE_ENTER = '13'
  9. urlParams = new URLSearchParams(window.location.search);
  10. var scene = urlParams.get('scene')
  11. var expe = urlParams.get('expe')
  12. function checkKey(e) {
  13. e = e || window.event;
  14. if (e.keyCode == KEYCODE_Q) {
  15. // `q` for quit expe
  16. console.log('`q` key is pressed')
  17. window.location = ''
  18. }
  19. else if (e.keyCode == KEYCODE_ENTER) {
  20. // right arrow
  21. var params = "?scene=" + scene + "&expe=" + expe + "&iteration=0"
  22. window.location = baseUrl + expe_url + params
  23. }
  24. }