Keyboard utilities for shortcut handling and platform detection
This module provides cross-platform keyboard shortcut handling with proper platform detection (Mac vs. Windows/Linux) and key combination parsing.
import { detectPlatform, getKeyCombination, formatKeyDisplay } from './keyboardUtils';// Detect user's platformconst platform = detectPlatform(); // 'mac' | 'windows' | 'linux' | 'unknown'// Handle keyboard eventdocument.addEventListener('keydown', (e) => { const combo = getKeyCombination(e); console.log('Pressed:', combo); // e.g., 'ctrl+shift+k'}); Copy
import { detectPlatform, getKeyCombination, formatKeyDisplay } from './keyboardUtils';// Detect user's platformconst platform = detectPlatform(); // 'mac' | 'windows' | 'linux' | 'unknown'// Handle keyboard eventdocument.addEventListener('keydown', (e) => { const combo = getKeyCombination(e); console.log('Pressed:', combo); // e.g., 'ctrl+shift+k'});
Keyboard utilities for shortcut handling and platform detection
This module provides cross-platform keyboard shortcut handling with proper platform detection (Mac vs. Windows/Linux) and key combination parsing.
Example