MCPcopy Create free account
hub / github.com/freecodexyz/free-code / keystrokeToDisplayString

Function keystrokeToDisplayString

src/keybindings/parser.ts:157–176  ·  view source on GitHub ↗
(
  ks: ParsedKeystroke,
  platform: DisplayPlatform = 'linux',
)

Source from the content-addressed store, hash-verified

155 * Uses "opt" for alt on macOS, "alt" elsewhere.
156 */
157export 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.

Callers 1

chordToDisplayStringFunction · 0.85

Calls 1

keyToDisplayNameFunction · 0.85

Tested by

no test coverage detected