Skip to content

Commit

Permalink
replace rest of event.keyCode usages by event.code
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Apr 14, 2023
1 parent 4879984 commit 4092fe2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/graphiql-react/src/editor/header-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export function useHeaderEditor(
});

newEditor.on('keyup', (editorInstance, event) => {
const { keyCode, key, shiftKey } = event;
const isLetter = keyCode >= 65 && keyCode <= 90;
const isNumber = keyCode >= 48 && keyCode <= 57;
const { code, key, shiftKey } = event;
const isLetter = code.startsWith('Key');
const isNumber = code.startsWith('Digit');
if (isLetter || (!shiftKey && isNumber) || key === '_' || key === '"') {
editorInstance.execCommand('autocomplete');
}
Expand Down
6 changes: 3 additions & 3 deletions packages/graphiql-react/src/editor/variable-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ export function useVariableEditor(
});

newEditor.on('keyup', (editorInstance, event) => {
const { keyCode, key, shiftKey } = event;
const isLetter = keyCode >= 65 && keyCode <= 90;
const isNumber = keyCode >= 48 && keyCode <= 57;
const { code, key, shiftKey } = event;
const isLetter = code.startsWith('Key');
const isNumber = code.startsWith('Digit');
if (isLetter || (!shiftKey && isNumber) || key === '_' || key === '"') {
editorInstance.execCommand('autocomplete');
}
Expand Down

0 comments on commit 4092fe2

Please sign in to comment.