1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-09-20 17:38:20 +03:00

dvorak shortcuts support - fixes #2544, fixes #2670

This commit is contained in:
Eugene Pankov 2021-03-20 17:12:25 +01:00
parent 2c11feed83
commit 4a97cc4383
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -10,6 +10,8 @@ export const altKeyName = {
linux: 'Alt',
}[process.platform]
const REGEX_LATIN_KEYNAME = /^[A-Za-z]$/
export function stringifyKeySequence (events: KeyboardEvent[]): string[] {
const items: string[] = []
events = events.slice()
@ -37,23 +39,29 @@ export function stringifyKeySequence (events: KeyboardEvent[]): string[] {
}
let key = event.code
key = key.replace('Key', '')
key = key.replace('Arrow', '')
key = key.replace('Digit', '')
key = {
Comma: ',',
Period: '.',
Slash: '/',
Backslash: '\\',
IntlBackslash: '\\',
Backquote: '`',
Minus: '-',
Equal: '=',
Semicolon: ';',
Quote: '\'',
BracketLeft: '[',
BracketRight: ']',
}[key] || key
if (REGEX_LATIN_KEYNAME.test(event.key)) {
// Handle Dvorak etc via the reported "character" instead of the scancode
key = event.key.toUpperCase()
} else {
key = key.replace('Key', '')
key = key.replace('Arrow', '')
key = key.replace('Digit', '')
key = {
Comma: ',',
Period: '.',
Slash: '/',
Backslash: '\\',
IntlBackslash: '\\',
Backquote: '`',
Minus: '-',
Equal: '=',
Semicolon: ';',
Quote: '\'',
BracketLeft: '[',
BracketRight: ']',
}[key] || key
}
itemKeys.push(key)
items.push(itemKeys.join('-'))
}