Skip to main content
Version: 4.0

isHotkeyPressed

This function allows us to check if the user is currently pressing down a key.

Basic Usage

Import the isHotkeyPressed function from the package:

import { isHotkeyPressed } from 'react-hotkeys-hook';

or if you are using require style syntax:

const { isHotkeyPressed } = require('react-hotkeys-hook')
// or
const isHotkeyPressed = require('react-hotkeys-hook').isHotkeyPressed

Check for pressed keys on callbacks

One common use case would be to check if the user holds down a modifier key.

Live Editor
Result
Loading...

Just like with useHotkeys, you can pass an array as the first argument to check for multiple keys.