k2nr / ViChrome

vi like key binds for Google Chrome
231 stars 40 forks source link

Add support for german keyboards #60

Open felixbarny opened 11 years ago

felixbarny commented 11 years ago

In key.js, the keys are currently hard coded to support japanese and us keyboard layouts, which seems a bit hacky to me. Whats the reason behind this? If you use the keypress callback rather than keypress in eventhandler.js, you can get the actual typed char regardless of the keyboard layout with String.fromCharCode(e.which).

In my local installation of this plugin, I changed the key identifiers for de, so if String.fromCharCode(e.which) is no option in your opinion, maybe you could add those mappings:

g.key.winKeyIdentifier_de = {
    "U+00BF": "#",
    "U+00DC": "^",
    "U+00E2": "<",
    "U+00BB": "+",
    "U+00BC": ",",
    "U+00BE": ".",   
    "U+00BD": "-",
  };

  g.key.shiftWinKeyIdentifier_de = {    
    "U+00E2": ">",
    "U+00DB": "?",    
    "U+00BE": ":",
    "U+00BD": "_",
    "U+00BB": "*",
    "U+0031": "!",
    "U+0032": '"',   
    "U+0034": "$",
    "U+0035": "%",
    "U+0036": "&",
    "U+0038": "(",
    "U+0039": ")",
    "U+0037": "/",
    "U+0030": "=",
    "U+00BC": ";",  
    "U+00BF": "'",
    "U+00DD": "`"

    // you need [Alt Gr] key for those
    //"U+0030": "}",
    //"U+0037": "{",
    //"U+00E2": "|",
    //"U+00BB": "~",
    //"U+0051": "@",
    //"U+0039": "]",
    //"U+0038": "[",
    //"U+00DB": "\\",
  };