keyboard fixes

This commit is contained in:
Jan Prochazka 2022-04-11 20:48:39 +02:00
parent 18437d1be7
commit e52fbd5034

View File

@ -42,20 +42,25 @@ export async function asyncFilter(arr, predicate) {
export function isMac() {
// @ts-ignore
const platform = navigator?.platform || navigator?.userAgentData?.platform || 'unknown'
const platform = navigator?.platform || navigator?.userAgentData?.platform || 'unknown';
return platform.toUpperCase().indexOf('MAC') >= 0;
}
export function formatKeyText(keyText: string): string {
if (isMac()) {
return keyText.replace('CtrlOrCommand+', '⌘ ').replace('Shift+', '⇧ ').replace('Alt+', '⌥ ')
return keyText
.replace('CtrlOrCommand+', '⌘ ')
.replace('Shift+', '⇧ ')
.replace('Alt+', '⌥ ')
.replace('Command+', '⌘ ')
.replace('Ctrl+', '⌃ ');
}
return keyText.replace('CtrlOrCommand+', 'Ctrl+');
}
export function resolveKeyText(keyText: string): string {
if (isMac()) {
return keyText.replace('CtrlOrCommand+', 'Command+')
return keyText.replace('CtrlOrCommand+', 'Command+');
}
return keyText.replace('CtrlOrCommand+', 'Ctrl+');
}
}