MCPcopy Create free account
hub / github.com/TanStack/hotkeys / isInputElement

Function isInputElement

packages/hotkeys/src/manager.utils.ts:48–75  ·  view source on GitHub ↗
(element: EventTarget | null)

Source from the content-addressed store, hash-verified

46 * Mod+S and Escape fire when the user has tabbed to a form button.
47 */
48export function isInputElement(element: EventTarget | null): boolean {
49 if (!element) {
50 return false
51 }
52
53 if (element instanceof HTMLInputElement) {
54 const type = element.type.toLowerCase()
55 if (type === 'button' || type === 'submit' || type === 'reset') {
56 return false
57 }
58 return true
59 }
60
61 if (
62 element instanceof HTMLTextAreaElement ||
63 element instanceof HTMLSelectElement
64 ) {
65 return true
66 }
67
68 // Check for contenteditable elements (includes "true", "", "plaintext-only",
69 // and inherited contenteditable from ancestor elements)
70 if (element instanceof HTMLElement && element.isContentEditable) {
71 return true
72 }
73
74 return false
75}
76
77/**
78 * Returns the focused element for the document associated with where hotkey

Callers 4

handlerMethod · 0.90
handlerMethod · 0.90
shouldIgnoreInputEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…