Skip to main content
Version: 11.14.0

isNotInputEvent

Returns true if the keyboard event did not originate from an <input> or <textarea> element. Useful for implementing global keyboard shortcuts that should not fire when the user is typing in a form field.

function isNotInputEvent(event: KeyboardEvent): boolean

Parameters

ParameterTypeRequiredDescription
eventKeyboardEventThe keyboard event to inspect

Returns booleantrue if the event target is NOT an <input> or <textarea>.

Example

global-shortcut.ts
import { isNotInputEvent } from '@sinequa/atomic';

document.addEventListener('keydown', (event) => {
if (isNotInputEvent(event)) {
// Safe to handle as a global shortcut
if (event.key === '/') {
openSearchBar();
}
}
});