( ks: ParsedKeystroke, platform: DisplayPlatform = 'linux', )
| 155 | * Uses "opt" for alt on macOS, "alt" elsewhere. |
| 156 | */ |
| 157 | export function keystrokeToDisplayString( |
| 158 | ks: ParsedKeystroke, |
| 159 | platform: DisplayPlatform = 'linux', |
| 160 | ): string { |
| 161 | const parts: string[] = [] |
| 162 | if (ks.ctrl) parts.push('ctrl') |
| 163 | // Alt/meta are equivalent in terminals, show platform-appropriate name |
| 164 | if (ks.alt || ks.meta) { |
| 165 | // Only macOS uses "opt", all other platforms use "alt" |
| 166 | parts.push(platform === 'macos' ? 'opt' : 'alt') |
| 167 | } |
| 168 | if (ks.shift) parts.push('shift') |
| 169 | if (ks.super) { |
| 170 | parts.push(platform === 'macos' ? 'cmd' : 'super') |
| 171 | } |
| 172 | // Use readable names for display |
| 173 | const displayKey = keyToDisplayName(ks.key) |
| 174 | parts.push(displayKey) |
| 175 | return parts.join('+') |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Convert a Chord to a platform-appropriate display string. |
no test coverage detected