mac specific keyboard shortcuts #199

This commit is contained in:
Jan Prochazka
2022-04-09 20:00:26 +02:00
parent 5379e86d6e
commit 90f8d349fc
22 changed files with 84 additions and 56 deletions

View File

@@ -39,3 +39,23 @@ export async function asyncFilter(arr, predicate) {
return arr.filter((_v, index) => results[index]);
}
export function isMac() {
// @ts-ignore
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+', 'Ctrl+');
}
export function resolveKeyText(keyText: string): string {
if (isMac()) {
return keyText.replace('CtrlOrCommand+', 'Command+')
}
return keyText.replace('CtrlOrCommand+', 'Ctrl+');
}