From f5312c04379bf185983b52cb34be9c81f68a8974 Mon Sep 17 00:00:00 2001 From: Aroonav Mishra Date: Tue, 15 May 2018 17:53:42 +0530 Subject: [PATCH 1/2] Add firefox keycodes for '=' and '-'. This should resolve issues referenced in pull request #215 (https://github.com/ccampbell/mousetrap/pull/215) --- mousetrap.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mousetrap.js b/mousetrap.js index 6e281461..3afe8aa3 100644 --- a/mousetrap.js +++ b/mousetrap.js @@ -72,9 +72,11 @@ var _KEYCODE_MAP = { 106: '*', 107: '+', + 61: '=', // FF keyCode for '=' (same as on keypress) 109: '-', 110: '.', 111 : '/', + 173: '-', // FF keyCode for '-' 186: ';', 187: '=', 188: ',', From 48bc59d265510324513dfc3c0d46ce4f848f20ac Mon Sep 17 00:00:00 2001 From: Aroonav Mishra Date: Wed, 16 May 2018 12:53:40 +0530 Subject: [PATCH 2/2] Check browser before adding FF's keycode for '-'. --- mousetrap.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mousetrap.js b/mousetrap.js index 3afe8aa3..2ec6b6f9 100644 --- a/mousetrap.js +++ b/mousetrap.js @@ -72,11 +72,9 @@ var _KEYCODE_MAP = { 106: '*', 107: '+', - 61: '=', // FF keyCode for '=' (same as on keypress) 109: '-', 110: '.', 111 : '/', - 173: '-', // FF keyCode for '-' 186: ';', 187: '=', 188: ',', @@ -90,6 +88,15 @@ 222: '\'' }; + /** + * Firefox's API "InstallTrigger" to install add-ons is unique to the browser. + * This is to resolve issues in https://github.com/ccampbell/mousetrap/pull/215/ + */ + var isFirefox = typeof InstallTrigger !== 'undefined'; + if (isFirefox) { + _KEYCODE_MAP[173] = '-'; // FF keyCode for '-' + } + /** * this is a mapping of keys that require shift on a US keypad * back to the non shift equivelents