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