From 3a94fbc0ae3789252e4ff2b08f5f10d89042be14 Mon Sep 17 00:00:00 2001 From: NostrDev Date: Fri, 1 Nov 2024 11:23:05 +0300 Subject: [PATCH] chore(types): used KeyboardCode enum --- src/pages/create/index.tsx | 8 ++++++-- src/pages/nostr/index.tsx | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index 866bdb5..c57bda0 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -21,7 +21,8 @@ import { ProfileMetadata, SignedEvent, User, - UserRole + UserRole, + KeyboardCode } from '../../types' import { encryptArrayBuffer, @@ -87,7 +88,10 @@ export const CreatePage = () => { const [userInput, setUserInput] = useState('') const handleInputKeyDown = (event: React.KeyboardEvent) => { - if (event.code === 'Enter' || event.code === 'NumpadEnter') { + if ( + event.code === KeyboardCode.Enter || + event.code === KeyboardCode.NumpadEnter + ) { event.preventDefault() handleAddUser() } diff --git a/src/pages/nostr/index.tsx b/src/pages/nostr/index.tsx index aa5f11c..5f2dc2f 100644 --- a/src/pages/nostr/index.tsx +++ b/src/pages/nostr/index.tsx @@ -9,6 +9,7 @@ import { toast } from 'react-toastify' import { LoadingSpinner } from '../../components/LoadingSpinner' import { AuthController } from '../../controllers' import { updateKeyPair, updateLoginMethod } from '../../store/actions' +import { KeyboardCode } from '../../types' import { LoginMethod } from '../../store/auth/types' import { hexToBytes } from '@noble/hashes/utils' @@ -52,7 +53,10 @@ export const Nostr = () => { * Call login function when enter is pressed */ const handleInputKeyDown = (event: React.KeyboardEvent) => { - if (event.code === 'Enter' || event.code === 'NumpadEnter') { + if ( + event.code === KeyboardCode.Enter || + event.code === KeyboardCode.NumpadEnter + ) { event.preventDefault() login() }