mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 22:38:41 +09:00
moebius#221: WebExtensions - commands API does not support shortcuts with space or numbers
https://github.com/MoonchildProductions/moebius/pull/221
This commit is contained in:
parent
b9ed9af662
commit
08e2f9aaea
1 changed files with 5 additions and 1 deletions
|
|
@ -163,11 +163,12 @@ CommandList.prototype = {
|
|||
// The modifiers are the remaining elements.
|
||||
keyElement.setAttribute("modifiers", this.getModifiersAttribute(parts));
|
||||
|
||||
if (/^[A-Z0-9]$/.test(chromeKey)) {
|
||||
if (/^[A-Z]$/.test(chromeKey)) {
|
||||
// We use the key attribute for all single digits and characters.
|
||||
keyElement.setAttribute("key", chromeKey);
|
||||
} else {
|
||||
keyElement.setAttribute("keycode", this.getKeycodeAttribute(chromeKey));
|
||||
keyElement.setAttribute("event", "keydown");
|
||||
}
|
||||
|
||||
return keyElement;
|
||||
|
|
@ -187,6 +188,9 @@ CommandList.prototype = {
|
|||
* @returns {string} The constructed value for the Key's 'keycode' attribute.
|
||||
*/
|
||||
getKeycodeAttribute(chromeKey) {
|
||||
if (/[0-9]/.test(chromeKey)) {
|
||||
return `VK_${chromeKey}`;
|
||||
}
|
||||
return `VK${chromeKey.replace(/([A-Z])/g, "_$&").toUpperCase()}`;
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue