All files / src/constants keyboardShortcuts.ts

100% Statements 7/7
100% Branches 0/0
100% Functions 0/0
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244                            23x                                                                                                                                                                                                                   23x                     23x                 23x                                                                                                                                                                       23x         23x         23x                  
/**
 * Centralized keyboard shortcut definitions
 * 
 * @module constants/keyboardShortcuts
 */
 
import { ShortcutCategory } from '../types/keyboard';
 
/**
 * Keyboard shortcut configuration constants
 * 
 * These shortcuts follow cross-platform conventions and avoid conflicts
 * with browser default shortcuts.
 */
export const KEYBOARD_SHORTCUTS = {
  // Security Level Selection (Alt+1-5 for None through Very High)
  // Note: Using Alt instead of Ctrl to avoid browser tab switching conflicts
  SELECT_NONE: {
    id: 'select-none',
    keys: 'alt+1',
    description: 'Set security level to None',
    category: 'Selection' as ShortcutCategory,
  },
  SELECT_LOW: {
    id: 'select-low',
    keys: 'alt+2',
    description: 'Set security level to Low',
    category: 'Selection' as ShortcutCategory,
  },
  SELECT_MODERATE: {
    id: 'select-moderate',
    keys: 'alt+3',
    description: 'Set security level to Moderate',
    category: 'Selection' as ShortcutCategory,
  },
  SELECT_HIGH: {
    id: 'select-high',
    keys: 'alt+4',
    description: 'Set security level to High',
    category: 'Selection' as ShortcutCategory,
  },
  SELECT_VERY_HIGH: {
    id: 'select-very-high',
    keys: 'alt+5',
    description: 'Set security level to Very High',
    category: 'Selection' as ShortcutCategory,
  },
  
  // Navigation (Ctrl+Shift+1-4 for widget categories)
  NAV_ASSESSMENT: {
    id: 'nav-assessment',
    keys: 'ctrl+shift+1',
    description: 'Navigate to Assessment Center',
    category: 'Navigation' as ShortcutCategory,
  },
  NAV_BUSINESS: {
    id: 'nav-business',
    keys: 'ctrl+shift+2',
    description: 'Navigate to Business Value',
    category: 'Navigation' as ShortcutCategory,
  },
  NAV_IMPACT: {
    id: 'nav-impact',
    keys: 'ctrl+shift+3',
    description: 'Navigate to Impact Analysis',
    category: 'Navigation' as ShortcutCategory,
  },
  NAV_IMPLEMENTATION: {
    id: 'nav-implementation',
    keys: 'ctrl+shift+4',
    description: 'Navigate to Implementation Guide',
    category: 'Navigation' as ShortcutCategory,
  },
  
  // Actions
  TOGGLE_COMPARISON: {
    id: 'toggle-comparison',
    keys: 'ctrl+m',
    description: 'Toggle comparison mode',
    category: 'Actions' as ShortcutCategory,
  },
  EXPORT_DATA: {
    id: 'export-data',
    keys: 'ctrl+shift+e',
    description: 'Export assessment data',
    category: 'Actions' as ShortcutCategory,
  },
  QUICK_SEARCH: {
    id: 'quick-search',
    keys: 'ctrl+shift+k',
    description: 'Quick search/filter',
    category: 'Actions' as ShortcutCategory,
    platformKeys: {
      mac: 'cmd+shift+k',
    },
  },
  SHOW_HELP: {
    id: 'show-help',
    keys: '?',
    description: 'Show keyboard shortcuts',
    category: 'Help' as ShortcutCategory,
  },
  SHOW_HELP_ALT: {
    id: 'show-help-alt',
    keys: 'ctrl+/',
    description: 'Show keyboard shortcuts (alternative)',
    category: 'Help' as ShortcutCategory,
  },
  // CLOSE_MODAL is handled locally by individual modal components
  // and doesn't need to be registered globally
} as const;
 
/**
 * Keyboard shortcut IDs for type-safe access
 */
export type KeyboardShortcutId = keyof typeof KEYBOARD_SHORTCUTS;
 
/**
 * Category labels for help display
 */
export const SHORTCUT_CATEGORY_LABELS: Record<ShortcutCategory, string> = {
  Selection: '🎯 Security Level Selection',
  Navigation: '🧭 Navigation',
  Actions: '⚡ Actions',
  Help: '❓ Help',
  General: '📋 General',
};
 
/**
 * Platform detection strings
 */
export const PLATFORM_DETECTION = {
  MAC: 'MAC',
  WINDOWS: 'WIN',
  LINUX: 'LINUX',
} as const;
 
/**
 * Key display names for different platforms
 */
export const KEY_DISPLAY_NAMES = {
  ctrl: {
    windows: 'Ctrl',
    mac: '⌘',
    linux: 'Ctrl',
    unknown: 'Ctrl',
  },
  shift: {
    windows: 'Shift',
    mac: '⇧',
    linux: 'Shift',
    unknown: 'Shift',
  },
  alt: {
    windows: 'Alt',
    mac: '⌥',
    linux: 'Alt',
    unknown: 'Alt',
  },
  meta: {
    windows: 'Win',
    mac: '⌘',
    linux: 'Meta',
    unknown: 'Meta',
  },
  cmd: {
    windows: 'Ctrl',
    mac: '⌘',
    linux: 'Ctrl',
    unknown: 'Ctrl',
  },
  enter: {
    windows: 'Enter',
    mac: '↵',
    linux: 'Enter',
    unknown: 'Enter',
  },
  escape: {
    windows: 'Esc',
    mac: 'Esc',
    linux: 'Esc',
    unknown: 'Esc',
  },
  backspace: {
    windows: 'Backspace',
    mac: '⌫',
    linux: 'Backspace',
    unknown: 'Backspace',
  },
  tab: {
    windows: 'Tab',
    mac: '⇥',
    linux: 'Tab',
    unknown: 'Tab',
  },
  arrowup: {
    windows: '↑',
    mac: '↑',
    linux: '↑',
    unknown: '↑',
  },
  arrowdown: {
    windows: '↓',
    mac: '↓',
    linux: '↓',
    unknown: '↓',
  },
  arrowleft: {
    windows: '←',
    mac: '←',
    linux: '←',
    unknown: '←',
  },
  arrowright: {
    windows: '→',
    mac: '→',
    linux: '→',
    unknown: '→',
  },
} as const;
 
/**
 * Keys that should not trigger shortcuts when focused in input elements
 */
export const INPUT_ELEMENT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'] as const;
 
/**
 * Keys that should bypass input element check
 */
export const BYPASS_INPUT_CHECK_KEYS = ['Escape', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12'] as const;
 
/**
 * Test IDs for keyboard shortcut components
 */
export const KEYBOARD_TEST_IDS = {
  HELP_MODAL: 'keyboard-shortcut-help-modal',
  HELP_MODAL_CLOSE: 'keyboard-shortcut-help-modal-close',
  HELP_MODAL_TITLE: 'keyboard-shortcut-help-modal-title',
  HELP_MODAL_CATEGORY: 'keyboard-shortcut-help-modal-category',
  HELP_MODAL_SHORTCUT: 'keyboard-shortcut-help-modal-shortcut',
  SHORTCUT_BADGE: 'keyboard-shortcut-badge',
  SHORTCUT_BADGE_KEY: 'keyboard-shortcut-badge-key',
} as const;