Skip to content
Permalink
Browse files

Fix: Use KeyboardEvent.key instead of KeyboardEvent.keyIdentifier

KeyboardEvent.keyIdentifier is removed in Chrome M54
  • Loading branch information...
haburibe committed Oct 16, 2016
1 parent 5002a42 commit 05ed8adf2771c2118f438799ce5cb2bfb1e16cf1
Showing with 8 additions and 274 deletions.
  1. +4 −4 Keyconfig/js/background.js
  2. +2 −136 Keyconfig/js/chrome_keyconfig.js
  3. +2 −134 Keyconfig/js/get_key.js
@@ -27,11 +27,11 @@ this.Keyconfig = {
"a a": {name: "focus first text input", args: []},
"C-d": {name: "navigate form elements forward", args: []},
"C-u": {name: "navigate form elements backward", args: []},
"Esc": {name: "limited mode", args: []},
"Escape": {name: "limited mode", args: []},
"c o n f i g": {name: "Keyconfig", args: []}
},
limited_actions: {
"Esc": {name: "normal mode", args: []}
"Escape": {name: "normal mode", args: []}
},
useTabTitle: false,
smooth_scroll: false,
@@ -45,11 +45,11 @@ this.Keyconfig = {
"l": {name: "Right", args: []},
"^": {name: "Line head", args: []},
"$": {name: "Line foot", args: []},
"Esc": {name: "normal mode", args: []},
"Escape": {name: "normal mode", args: []},
"i": {name: "insert mode", args: []}
},
vim_insert_actions: {
"Esc": {name: "normal mode", args: []}
"Escape": {name: "normal mode", args: []}
},
vim_default_mode: 'insert',
vim_color_config: {
@@ -3,150 +3,16 @@
// license http://creativecommons.org/licenses/MIT/ (The MIT license)

(function () {
var keyId = {
"U+0008": "BackSpace",
"U+0009": "Tab",
"U+0018": "Cancel",
"U+001B": "Esc",
"U+0020": "Space",
"U+0021": "!",
"U+0022": "\"",
"U+0023": "#",
"U+0024": "$",
"U+0026": "&",
"U+0027": "'",
"U+0028": "(",
"U+0029": ")",
"U+002A": "*",
"U+002B": "+",
"U+002C": ",",
"U+002D": "-",
"U+002E": ".",
"U+002F": "/",
"U+0030": "0",
"U+0031": "1",
"U+0032": "2",
"U+0033": "3",
"U+0034": "4",
"U+0035": "5",
"U+0036": "6",
"U+0037": "7",
"U+0038": "8",
"U+0039": "9",
"U+003A": ":",
"U+003B": ";",
"U+003C": "<",
"U+003D": "=",
"U+003E": ">",
"U+003F": "?",
"U+0040": "@",
"U+0041": "a",
"U+0042": "b",
"U+0043": "c",
"U+0044": "d",
"U+0045": "e",
"U+0046": "f",
"U+0047": "g",
"U+0048": "h",
"U+0049": "i",
"U+004A": "j",
"U+004B": "k",
"U+004C": "l",
"U+004D": "m",
"U+004E": "n",
"U+004F": "o",
"U+0050": "p",
"U+0051": "q",
"U+0052": "r",
"U+0053": "s",
"U+0054": "t",
"U+0055": "u",
"U+0056": "v",
"U+0057": "w",
"U+0058": "x",
"U+0059": "y",
"U+005A": "z",
"U+005B": "[",
"U+005C": "\\",
"U+005D": "]",
"U+005E": "^",
"U+005F": "_",
"U+0060": "`",
"U+007B": "{",
"U+007C": "|",
"U+007D": "}",
"U+007F": "Delete"
};
var winkeys = {
"U+00BC": ",",
"U+00BE": ".",
"U+00BF": "/",
"U+00E2": "\\",
"U+00BB": ";",
"U+00BA": ":",
"U+00DD": "]",
"U+00C0": "@",
"U+00DB": "[",
"U+00BD": "-",
"U+00DE": "^",
"U+00DC": "\\"
};
var shiftWinkeys = {
"U+0031": "!",
"U+0032": "\"",
"U+0033": "#",
"U+0034": "$",
"U+0035": "%",
"U+0036": "&",
"U+0037": "'",
"U+0038": "(",
"U+0039": ")",
"U+00BA": "*",
"U+00BB": "+",
"U+00BC": "<",
"U+00BD": "=",
"U+00BE": ">",
"U+00BF": "?",
"U+00C0": "`",
"U+00DB": "{",
"U+00DC": "|",
"U+00DD": "}",
"U+00DE": "~",
"U+00E2": "_"
};
var shiftLinuxkeys = {
"U+0030": ")",
"U+0031": "!",
"U+0033": "#",
"U+0034": "$",
"U+0035": "%",
"U+0037": "&",
"U+0038": "*",
"U+0039": "(",
"U+00BB": "+",
"U+00BC": "<",
"U+00BD": "_",
"U+00BE": ">",
"U+00BF": "?",
"U+00C0": "~",
"U+00DB": "{",
"U+00DC": "|",
"U+00DD": "}",
"U+00DE": "\""
};
var shiftKeysfix = /linux/i.test(navigator.platform) ? shiftLinuxkeys : shiftWinkeys;

function get_key(evt) {
var key = keyId[evt.keyIdentifier] || winkeys[evt.keyIdentifier] || evt.keyIdentifier,
var key = evt.key === ' ' ? 'Space' : evt.key,
ctrl = evt.ctrlKey ? 'C-' : '',
meta = (evt.metaKey || evt.altKey) ? 'M-' : '',
shift = evt.shiftKey ? 'S-' : '';
if (evt.shiftKey && shiftKeysfix[evt.keyIdentifier]) key = shiftKeysfix[evt.keyIdentifier];
if (/^(Meta|Shift|Control|Alt)$/.test(key)) return key;
if (evt.shiftKey) {
if (/^[a-z]$/.test(key))
return ctrl + meta + key.toUpperCase();
if (/^(Enter|Space|BackSpace|Tab|Esc|Home|End|Left|Right|Up|Down|PageUp|PageDown|Delete|F\d\d?)$/.test(key))
if (/^(Enter|Space|BackSpace|Tab|Escape|Home|End|AllowLeft|AllowRight|AllowUp|AllowDown|PageUp|PageDown|Delete|F\d\d?)$/.test(key))
return ctrl + meta + shift + key;
}
return ctrl + meta + key;
@@ -1,145 +1,13 @@
var keyId = {
"U+0008" : "BackSpace",
"U+0009" : "Tab",
"U+0018" : "Cancel",
"U+001B" : "Esc",
"U+0020" : "Space",
"U+0021" : "!",
"U+0022" : "\"",
"U+0023" : "#",
"U+0024" : "$",
"U+0026" : "&",
"U+0027" : "'",
"U+0028" : "(",
"U+0029" : ")",
"U+002A" : "*",
"U+002B" : "+",
"U+002C" : ",",
"U+002D" : "-",
"U+002E" : ".",
"U+002F" : "/",
"U+0030" : "0",
"U+0031" : "1",
"U+0032" : "2",
"U+0033" : "3",
"U+0034" : "4",
"U+0035" : "5",
"U+0036" : "6",
"U+0037" : "7",
"U+0038" : "8",
"U+0039" : "9",
"U+003A" : ":",
"U+003B" : ";",
"U+003C" : "<",
"U+003D" : "=",
"U+003E" : ">",
"U+003F" : "?",
"U+0040" : "@",
"U+0041" : "a",
"U+0042" : "b",
"U+0043" : "c",
"U+0044" : "d",
"U+0045" : "e",
"U+0046" : "f",
"U+0047" : "g",
"U+0048" : "h",
"U+0049" : "i",
"U+004A" : "j",
"U+004B" : "k",
"U+004C" : "l",
"U+004D" : "m",
"U+004E" : "n",
"U+004F" : "o",
"U+0050" : "p",
"U+0051" : "q",
"U+0052" : "r",
"U+0053" : "s",
"U+0054" : "t",
"U+0055" : "u",
"U+0056" : "v",
"U+0057" : "w",
"U+0058" : "x",
"U+0059" : "y",
"U+005A" : "z",
"U+005B" : "[",
"U+005C" : "\\",
"U+005D" : "]",
"U+005E" : "^",
"U+005F" : "_",
"U+0060" : "`",
"U+007B" : "{",
"U+007C" : "|",
"U+007D" : "}",
"U+007F" : "Delete",
/* unsupported
"U+00A1" : "RevExcl",
"U+0300" : "CombGrave",
"U+0300" : "CombAcute",
"U+0302" : "CombCircum",
"U+0303" : "CombTilde",
"U+0304" : "CombMacron",
"U+0306" : "CombBreve",
"U+0307" : "CombDot",
"U+0308" : "CombDiaer",
"U+030A" : "CombRing",
"U+030B" : "CombDblAcute",
"U+030C" : "CombCaron",
"U+0327" : "CombCedilla",
"U+0328" : "CombOgonek",
"U+0345" : "CombYpogeg",
"U+20AC" : "Euro",
"U+3099" : "CombVoice",
"U+309A" : "CombSVoice",
*/
};
var winkeys = {
"U+00BC":",",
"U+00BE":".",
"U+00BF":"/",
"U+00E2":"\\",
"U+00BB":";",
"U+00BA":":",
"U+00DD":"]",
"U+00C0":"@",
"U+00DB":"[",
"U+00BD":"-",
"U+00DE":"^",
"U+00DC":"\\"
};
var shiftWinkeys = {
"U+00BC":"<",
"U+00BE":">",
"U+00BF":"?",
"U+00E2":"_",
"U+00BB":"+",
"U+00BA":"*",
"U+00DD":"}",
"U+00C0":"`",
"U+00DB":"{",
"U+00BD":"=",
"U+00DE":"~",
"U+00DC":"|",
"U+0031":"!",
"U+0032":"\"",
"U+0033":"#",
"U+0034":"$",
"U+0035":"%",
"U+0036":"&",
"U+0037":"'",
"U+0038":"(",
"U+0039":")"
};
function get_key(evt){
var key = keyId[evt.keyIdentifier] || winkeys[evt.keyIdentifier] || evt.keyIdentifier,
var key = evt.key === ' ' ? 'Space' : evt.key,
ctrl = evt.ctrlKey ? 'C-' : '',
meta = (evt.metaKey || evt.altKey) ? 'M-' : '',
shift = evt.shiftKey ? 'S-' : '';
if (evt.shiftKey && shiftWinkeys[evt.keyIdentifier]) key = shiftWinkeys[evt.keyIdentifier];
if (/^(Meta|Shift|Control|Alt)$/.test(key)) return key;
if (evt.shiftKey){
if (/^[a-z]$/.test(key))
return ctrl+meta+key.toUpperCase();
if (/^(Enter|Space|BackSpace|Tab|Esc|Home|End|Left|Right|Up|Down|PageUp|PageDown|Delete|F\d\d?)$/.test(key))
if (/^(Enter|Space|BackSpace|Tab|Escape|Home|End|AllowLeft|AllowRight|AllowUp|AllowDown|PageUp|PageDown|Delete|F\d\d?)$/.test(key))
return ctrl+meta+shift+key;
}
return ctrl+meta+key;

0 comments on commit 05ed8ad

Please sign in to comment.
You can’t perform that action at this time.