mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-04 18:19:54 +00:00
Make shortcuts work outside of English layout (#227)
The keyboard event is tested two times: first time with the original key property, second time with the key property derived from the key code. This is done to support non-English shortcuts (which may be added by wiki administrators).
This commit is contained in:
parent
afe2f0c9e2
commit
b43f2836c1
@ -57,9 +57,23 @@ rrh.shortcuts = {
|
||||
if ((!event.ctrlKey && !event.metaKey && !event.altKey) &&
|
||||
event.target instanceof Node && isTextField(event.target)) return
|
||||
|
||||
let shortcut = keyEventToShortcut(event)
|
||||
let possibleShortcuts = [keyEventToShortcut(event)]
|
||||
if (event.code.startsWith('Key')) {
|
||||
possibleShortcuts.push(keyEventToShortcut({
|
||||
...event,
|
||||
key: event.code.replace(/^Key/, '').toLowerCase(),
|
||||
}))
|
||||
}
|
||||
|
||||
if (!this.active[shortcut]) {
|
||||
let shortcut = null
|
||||
for (let possibleShortcut of possibleShortcuts) {
|
||||
if (possibleShortcut in this.active) {
|
||||
shortcut = possibleShortcut
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (shortcut === null) {
|
||||
this._resetActive()
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user