From 22abd1b269efd853bb2d77285f2c4c01de61a957 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Fri, 18 Aug 2023 15:40:11 -0700 Subject: [PATCH 1/3] fix: remove backspace listener --- editor/js/Sidebar.Settings.Shortcuts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/js/Sidebar.Settings.Shortcuts.js b/editor/js/Sidebar.Settings.Shortcuts.js index a8847f471f1012..e25a39d8de35a1 100644 --- a/editor/js/Sidebar.Settings.Shortcuts.js +++ b/editor/js/Sidebar.Settings.Shortcuts.js @@ -101,7 +101,7 @@ function SidebarSettingsShortcuts( editor ) { case 'backspace': - event.preventDefault(); // prevent browser back + // event.preventDefault(); // prevent browser back -- this is no longer an issue since 2016 // fall-through From ad7deb387f1fe6f2894f56a5affc54a8619509a9 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:02:29 -0700 Subject: [PATCH 2/3] update: add event listeners to threejs editor only --- editor/js/Sidebar.Settings.Shortcuts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/js/Sidebar.Settings.Shortcuts.js b/editor/js/Sidebar.Settings.Shortcuts.js index e25a39d8de35a1..6067f288306eac 100644 --- a/editor/js/Sidebar.Settings.Shortcuts.js +++ b/editor/js/Sidebar.Settings.Shortcuts.js @@ -95,13 +95,13 @@ function SidebarSettingsShortcuts( editor ) { } - document.addEventListener( 'keydown', function ( event ) { + document.getElementById( 'threejs-editor' ).addEventListener( 'keydown', function ( event ) { switch ( event.key.toLowerCase() ) { case 'backspace': - // event.preventDefault(); // prevent browser back -- this is no longer an issue since 2016 + event.preventDefault(); // prevent browser back -- this is no longer an issue since 2016 // fall-through From d4a6a3f9044e18af4514a85e1dc715980c5f960b Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:44:02 -0700 Subject: [PATCH 3/3] update: name event listener to possibly access it elsewhere --- editor/js/Sidebar.Settings.Shortcuts.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/js/Sidebar.Settings.Shortcuts.js b/editor/js/Sidebar.Settings.Shortcuts.js index 6067f288306eac..4840dff1381ad8 100644 --- a/editor/js/Sidebar.Settings.Shortcuts.js +++ b/editor/js/Sidebar.Settings.Shortcuts.js @@ -95,13 +95,13 @@ function SidebarSettingsShortcuts( editor ) { } - document.getElementById( 'threejs-editor' ).addEventListener( 'keydown', function ( event ) { + function shortcutsListener( event ) { switch ( event.key.toLowerCase() ) { case 'backspace': - event.preventDefault(); // prevent browser back -- this is no longer an issue since 2016 + // event.preventDefault(); // prevent browser back -- this is no longer an issue since 2016 // fall-through @@ -172,7 +172,9 @@ function SidebarSettingsShortcuts( editor ) { } - } ); + } + + document.addEventListener( 'keydown', shortcutsListener ); return container;