MCPcopy Create free account
hub / github.com/Kong/insomnia / displayModifierKey

Function displayModifierKey

packages/insomnia-data/common-src/hotkeys.ts:272–307  ·  view source on GitHub ↗
(key: keyof Omit<KeyCombination, 'keyCode'>)

Source from the content-addressed store, hash-verified

270}
271
272export const displayModifierKey = (key: keyof Omit<KeyCombination, 'keyCode'>) => {
273 const mac = isMac;
274 switch (key) {
275 case 'ctrl': {
276 return mac ? '⌃' : 'Ctrl';
277 }
278
279 case 'alt': {
280 return mac ? '⌥' : 'Alt';
281 }
282
283 case 'shift': {
284 return mac ? '⇧' : 'Shift';
285 }
286
287 case 'meta': {
288 if (mac) {
289 return '⌘';
290 }
291
292 if (isWindows) {
293 // Note: Although this unicode character for the Windows doesn't exist, the Unicode character U+229E ⊞ SQUARED PLUS is very commonly used for this purpose. For example, Wikipedia uses it as a simulation of the windows logo. Though, Windows itself uses `Windows` or `Win`, so we'll go with `Win` here.
294 // see: https://en.wikipedia.org/wiki/Windows_key
295 return 'Win';
296 }
297
298 // Note: To avoid using a Microsoft trademark, much Linux documentation refers to the key as "Super". This can confuse some users who still consider it a "Windows key". In KDE Plasma documentation it is called the Meta key even though the X11 "Super" shift bit is used.
299 // see: https://en.wikipedia.org/wiki/Super_key_(keyboard_button)
300 return 'Super';
301 }
302
303 default: {
304 throw new Error(key + 'unrecognized key');
305 }
306 }
307};
308
309/**
310 * Construct the display string of a key combination based on platform.

Callers 1

addModifierKeysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected