Skip to content

clickElementOnKeydownEvent

Function which, given a triggering code, executes click on element when a keyDown event with triggering code is executed.

Types

ClickElementOnKeydownEventProps

Parameters accepted by clickElementOnKeydownEvent.

A {@link KeyboardEventCode} string identifying the key that triggers a programmatic .click() on the focused element when pressed (e.g. "Enter", "Space"). Returns a stable keydown event handler to attach to a DOM element or document.

ts
export type ClickElementOnKeydownEventProps = KeyboardEventCode;

ClickElementOnKeydownEventResult

Return value of clickElementOnKeydownEvent.

A keydown event handler that calls .click() on document.activeElement whenever the configured key code is pressed.

ts
export type ClickElementOnKeydownEventResult = (e: KeyboardEvent) => void;

Released under the MIT License.