sdxc

Type to search, or start from one of these:

[ @sdxc/ui/mixins ]

hotkey

Global keyboard-shortcut mixin for a Command dialog or any dialog/popover host.

import { hotkey } from "@sdxc/ui/mixins";

Usage

Opens the host when combo is struck anywhere in the document while it's closed, and closes it again on the same combo while it's already open, driving the host's own native <dialog> or [popover] open state.

Signature

hotkey(combo: string): MixinDescriptor<HTMLElement>

Parameters

ParameterTypeDescription
combostringKey combination that opens or closes the host, e.g. "mod+k".

Examples

<dialog id="command-palette" mix={[hotkey("mod+k")]}>
	<Command>...</Command>
</dialog>
<div id="quick-switcher" popover="manual" mix={[hotkey("mod+shift+k")]}>
	...
</div>

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.