NeoTerm UI

useHotkey

Listen for keyboard shortcut combos.

Import

import { useHotkey } from "neoterm-ui";

Usage

useHotkey("Meta+k", () => setCommandPaletteOpen(true));
useHotkey("Ctrl+Shift+p", () => togglePreview());
useHotkey("Escape", () => closeModal());

Signature

function useHotkey(combo: string, callback: () => void): void

Parameters

PropTypeDefaultDescription
combostringKey combo string, e.g. "Meta+k", "Ctrl+Shift+p".
callback() => voidFunction called when the combo is pressed.