Created
October 2, 2017 21:49
-
-
Save sergiopvilar/772f9bb39d0cc46b35e4eaacb389d736 to your computer and use it in GitHub Desktop.
Translate DVORAK hotkeys to QWERTY in Atom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
atom.keymaps.addKeystrokeResolver(({keystroke, event}) => { | |
var qKeys = "q w e r t y u i o p [ ] a s d f g h j k l ; ' z x c v b n m , . /".split(' ') | |
, dvorakKeys = "' , . p y f g c r l / = a o e u i d h t n s - ; q j k x b m w v z".split(' ') | |
, key = keystroke | |
, replaced = []; | |
if(event.type == 'keydown' && event.metaKey && event.key !== 'Meta' && keystroke.startsWith('cmd-')) { | |
for(var i in dvorakKeys) { | |
if( | |
key.indexOf('-' + dvorakKeys[i]) > -1 && | |
replaced.indexOf(dvorakKeys[i]) == -1 && | |
(key.endsWith('-' + dvorakKeys[i]) || key.indexOf('-'+dvorakKeys[i]+'-') > -1) | |
) { | |
key = key.replace('-' + dvorakKeys[i], '-' + qKeys[i]); | |
replaced.push(qKeys[i]); | |
} | |
} | |
if(keystroke !== key) console.log(keystroke + ' translated to ' + key); | |
return key; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment