summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-23 08:51:40 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-23 08:51:40 +0200
commite2649bc086f764859c94592b28237dab7d557493 (patch)
tree1338309a5d7b8d7073df5b590d49f24922486ec5
parentc30ebdac27c93b57e368c69e9c13055a17229992 (diff)
downloadUXP-e2649bc086f764859c94592b28237dab7d557493.tar
UXP-e2649bc086f764859c94592b28237dab7d557493.tar.gz
UXP-e2649bc086f764859c94592b28237dab7d557493.tar.lz
UXP-e2649bc086f764859c94592b28237dab7d557493.tar.xz
UXP-e2649bc086f764859c94592b28237dab7d557493.zip
moebius#221: WebExtensions - commands API does not support shortcuts with space or numbers
https://github.com/MoonchildProductions/moebius/pull/221
-rw-r--r--browser/components/webextensions/ext-commands.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/browser/components/webextensions/ext-commands.js b/browser/components/webextensions/ext-commands.js
index 3f0bf8d1a..b6e7ab3d1 100644
--- a/browser/components/webextensions/ext-commands.js
+++ b/browser/components/webextensions/ext-commands.js
@@ -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()}`;
},