From 4bb2c5f7c7b547c4b84eead83f3f7b22edf7b6a0 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Mon, 18 Jan 2021 23:43:30 +0100 Subject: [PATCH] Switch shortcut keycode to work for Firefox --- app/assets/javascripts/editor/editor.js.erb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index 91fae9ef..841c063e 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -9,9 +9,9 @@ var CodeOceanEditor = { SUCCESSFULL_PERCENTAGE: 90, //Key-Codes (for Hotkeys) - ALT_R_KEY_CODE: 174, - ALT_S_KEY_CODE: 8218, - ALT_T_KEY_CODE: 8224, + R_KEY_CODE: 82, + S_KEY_CODE: 83, + T_KEY_CODE: 84, ENTER_KEY_CODE: 13, //Request-For-Comments-Configuration @@ -167,11 +167,11 @@ var CodeOceanEditor = { }, handleKeyPress: function (event) { - if (event.which === this.ALT_R_KEY_CODE) { + if (event.altKey && event.which === this.R_KEY_CODE) { $('#run').trigger('click'); - } else if (event.which === this.ALT_S_KEY_CODE) { + } else if (event.altKey && event.which === this.S_KEY_CODE) { $('#assess').trigger('click'); - } else if (event.which === this.ALT_T_KEY_CODE) { + } else if (event.altKey && event.which === this.T_KEY_CODE) { $('#test').trigger('click'); } else { return; @@ -302,7 +302,7 @@ var CodeOceanEditor = { initializeEventHandlers: function () { $(document).on('click', '#results a', this.showOutput.bind(this)); - $(document).on('keypress', this.handleKeyPress.bind(this)); + $(document).on('keydown', this.handleKeyPress.bind(this)); this.initializeFileTreeButtons(); this.initializeWorkspaceButtons(); this.initializeRequestForComments()