use-hotkeys
Listen for keys combinations on document element
Import
Source
Docs
Package
Usage
Hook accepts an array with hotkey and handler tuples:
hotkey
- hotkey string e.g.ctrl+E
,shift+alt+L
,mod+S
handler
- event handler called when given combination was pressed
Targeting elements
use-hotkeys hook can work only with document element, you will need to create your own event listener
if you need to support other elements. For this purpose package exports getHotkeysHandler
function
which should be used with onKeyDown
:
Supported formats
mod+S
– detects⌘+S
on macOS andCtrl+S
on Windowsctrl+shift+X
– handles multiple modifiersalt + shift + L
– you can use whitespace inside hotkeyArrowLeft
– you can use special keys using this format
Definition
Feedback
Your feedback is most valuable contribution to the project, please share how you use Mantine, what features are missing and what is done good
Leave feedback