Skip to main content
Version: 4.0

Advanced Usage

This section described advanced functionalities of the hook.

🚧 This section is under construction 🚧

Using typescript types to reference key names​

Sometimes we might get confused if we need to listen to ArrowLeft or LeftArrow to listen to the left arrow key. To avoid this confusion, we can use the typescript types provided by the ts-key-now library.

You add the library to your project by running:

npm install ts-key-enum

Then you can import the types and use them in your code:

import { Key } from 'ts-key-enum'

useHotkeys(Key.Backspace, () => {
console.log(`delete`)
})

See https://gitlab.com/nfriend/ts-key-enum/-/blob/master/Key.enum.d.ts for the full list of available keys.