Service console check providers

This commit is contained in:
Stijnus
2025-01-30 01:58:47 +01:00
parent 9e8d05cb54
commit d9a380f28a
22 changed files with 1476 additions and 104 deletions

View File

@@ -25,26 +25,57 @@ export function useShortcuts(): void {
useEffect(() => {
const handleKeyDown = (event: KeyboardEvent): void => {
const { key, ctrlKey, shiftKey, altKey, metaKey } = event;
// Debug logging
console.log('Key pressed:', {
key: event.key,
code: event.code, // This gives us the physical key regardless of modifiers
ctrlKey: event.ctrlKey,
shiftKey: event.shiftKey,
altKey: event.altKey,
metaKey: event.metaKey,
});
/*
* Check for theme toggle shortcut first (Option + Command + Shift + D)
* Use event.code to check for the physical D key regardless of the character produced
*/
if (
event.code === 'KeyD' &&
event.metaKey && // Command (Mac) or Windows key
event.altKey && // Option (Mac) or Alt (Windows)
event.shiftKey &&
!event.ctrlKey
) {
event.preventDefault();
event.stopPropagation();
shortcuts.toggleTheme.action();
return;
}
// Handle other shortcuts
for (const name in shortcuts) {
const shortcut = shortcuts[name as keyof Shortcuts];
if (
shortcut.key.toLowerCase() === key.toLowerCase() &&
(shortcut.ctrlOrMetaKey
? ctrlKey || metaKey
: (shortcut.ctrlKey === undefined || shortcut.ctrlKey === ctrlKey) &&
(shortcut.metaKey === undefined || shortcut.metaKey === metaKey)) &&
(shortcut.shiftKey === undefined || shortcut.shiftKey === shiftKey) &&
(shortcut.altKey === undefined || shortcut.altKey === altKey)
) {
shortcutEventEmitter.dispatch(name as keyof Shortcuts);
if (name === 'toggleTheme') {
continue;
} // Skip theme toggle as it's handled above
// For other shortcuts, check both key and code
const keyMatches =
shortcut.key.toLowerCase() === event.key.toLowerCase() || `Key${shortcut.key.toUpperCase()}` === event.code;
const modifiersMatch =
(shortcut.ctrlKey === undefined || shortcut.ctrlKey === event.ctrlKey) &&
(shortcut.metaKey === undefined || shortcut.metaKey === event.metaKey) &&
(shortcut.shiftKey === undefined || shortcut.shiftKey === event.shiftKey) &&
(shortcut.altKey === undefined || shortcut.altKey === event.altKey);
if (keyMatches && modifiersMatch) {
event.preventDefault();
event.stopPropagation();
shortcutEventEmitter.dispatch(name as keyof Shortcuts);
shortcut.action();
break;
}
}