@@ -14,6 +14,21 @@ interface KeyboardState {
1414 shortcuts : Map < string , Shortcut > ;
1515}
1616
17+ /**
18+ * True when the user is typing into an editable element, so global keyboard
19+ * shortcuts (single letters like `h`, arrow keys, etc.) must not fire.
20+ * Shared by the central store and component-local window handlers.
21+ */
22+ export function isInputFocused ( ) : boolean {
23+ if ( ! browser ) return false ;
24+ const activeElement = document . activeElement ;
25+ return (
26+ activeElement instanceof HTMLInputElement ||
27+ activeElement instanceof HTMLTextAreaElement ||
28+ activeElement ?. getAttribute ( 'contenteditable' ) === 'true'
29+ ) ;
30+ }
31+
1732function createKeyboardStore ( ) {
1833 let state = $state < KeyboardState > ( {
1934 isHelpOpen : false ,
@@ -34,16 +49,6 @@ function createKeyboardStore() {
3449 state . shortcuts . delete ( shortcutKey ) ;
3550 }
3651
37- function isInputFocused ( ) : boolean {
38- if ( ! browser ) return false ;
39- const activeElement = document . activeElement ;
40- return (
41- activeElement instanceof HTMLInputElement ||
42- activeElement instanceof HTMLTextAreaElement ||
43- activeElement ?. getAttribute ( 'contenteditable' ) === 'true'
44- ) ;
45- }
46-
4752 function handleKeydown ( e : KeyboardEvent ) {
4853 // Always allow Escape
4954 if ( e . key === 'Escape' ) {
0 commit comments