mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Special handling of Backspace/Delete etc. for displaying shortcuts
This commit is contained in:
parent
6d21c16250
commit
280a724957
2 changed files with 16 additions and 2 deletions
|
@ -59,3 +59,17 @@ export function modifiersToPlatformString(modifiers: string[]): string {
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function keyToPlatformString(key: string): string {
|
||||
switch (key) {
|
||||
case "Backspace":
|
||||
return "⌫";
|
||||
case "Delete":
|
||||
return "⌦";
|
||||
case "Escape":
|
||||
return "⎋";
|
||||
|
||||
default:
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import type { Modifier } from "./keys";
|
||||
|
||||
import { registerPackage } from "./register-package";
|
||||
import { modifiersToPlatformString, checkModifiers } from "./keys";
|
||||
import { modifiersToPlatformString, keyToPlatformString, checkModifiers } from "./keys";
|
||||
|
||||
const keyCodeLookup = {
|
||||
Backspace: 8,
|
||||
|
@ -48,7 +48,7 @@ function toPlatformString(keyCombination: string[]): string {
|
|||
return (
|
||||
modifiersToPlatformString(
|
||||
keyCombination.slice(0, -1).filter(isRequiredModifier)
|
||||
) + keyCombination[keyCombination.length - 1]
|
||||
) + keyToPlatformString(keyCombination[keyCombination.length - 1])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue