File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
packages/react-hotkeys-hook/src/lib Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ export type Options = {
8787 sequenceTimeoutMs ?: number
8888 // The character to split the sequence of keys. (Default: >)
8989 sequenceSplitKey ?: string
90+ // Ignore repeated events when the key is held down. (Default: false)
91+ ignoreRepeat ?: boolean
9092 // MetaData | Custom data to store and retrieve with the hotkey (Default: undefined)
9193 metadata ?: Record < string , unknown >
9294}
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ export default function useHotkeys<T extends HTMLElement>(
6767 let sequenceTimer : NodeJS . Timeout | undefined
6868
6969 const listener = ( e : KeyboardEvent , isKeyUp = false ) => {
70+ if ( memoisedOptions ?. ignoreRepeat && e . repeat ) {
71+ return
72+ }
73+
7074 if ( isKeyboardEventTriggeredByInput ( e ) && ! isHotkeyEnabledOnTag ( e , memoisedOptions ?. enableOnFormTags ) ) {
7175 return
7276 }
You can’t perform that action at this time.
0 commit comments