From 4092fe2b8a6d7cd162b7e5545f23e133f023f73a Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Sat, 15 Apr 2023 01:35:51 +0200 Subject: [PATCH] replace rest of `event.keyCode` usages by `event.code` --- packages/graphiql-react/src/editor/header-editor.ts | 6 +++--- packages/graphiql-react/src/editor/variable-editor.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/graphiql-react/src/editor/header-editor.ts b/packages/graphiql-react/src/editor/header-editor.ts index 19e8727c316..8fea2252564 100644 --- a/packages/graphiql-react/src/editor/header-editor.ts +++ b/packages/graphiql-react/src/editor/header-editor.ts @@ -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'); } diff --git a/packages/graphiql-react/src/editor/variable-editor.ts b/packages/graphiql-react/src/editor/variable-editor.ts index d3c54ac995b..8c82d43995d 100644 --- a/packages/graphiql-react/src/editor/variable-editor.ts +++ b/packages/graphiql-react/src/editor/variable-editor.ts @@ -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'); }