Revert "Add keycode table and switch to event.code in select places" (#224)

Using code instead of key is strongly warned against at MDN and causes issues with nonstandard layouts:
https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event#keyboardevent.code

This also fixes ScriptEditorRoot.tsx, where some code snuck in that
wasn't using *any* of the constants.

This reverts commit 016a9a873f.
This commit is contained in:
David Walker
2022-11-26 05:51:09 -08:00
committed by GitHub
parent f70a25d755
commit 70fadde222
4 changed files with 33 additions and 96 deletions

View File

@@ -4,6 +4,7 @@ import * as monaco from "monaco-editor";
type IStandaloneCodeEditor = monaco.editor.IStandaloneCodeEditor;
type ITextModel = monaco.editor.ITextModel;
import { KEY } from "../../utils/helpers/keyCodes";
import { OptionsModal } from "./OptionsModal";
import { Options } from "./Options";
import { isValidFilePath } from "../../Terminal/DirectoryHelpers";
@@ -152,13 +153,13 @@ export function Root(props: IProps): React.ReactElement {
function keydown(event: KeyboardEvent): void {
if (Settings.DisableHotkeys) return;
//Ctrl + b
if (event.code == "KeyB" && (event.ctrlKey || event.metaKey)) {
if (event.key == KEY.B && (event.ctrlKey || event.metaKey)) {
event.preventDefault();
Router.toTerminal();
}
// CTRL/CMD + S
if (event.code == "KeyS" && (event.ctrlKey || event.metaKey)) {
if (event.key == KEY.S && (event.ctrlKey || event.metaKey)) {
event.preventDefault();
event.stopPropagation();
save();