Created
November 19, 2014 03:24
-
-
Save hyamamoto/c9b35cdb59e6fd5e6132 to your computer and use it in GitHub Desktop.
Getting a list of keys next to a given key according to a physical layout of the keyboard. Converted from zxcvbn code. Only to realize I can't use this for English Dvorak.
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
Map<String, List<String>> _DICT_KEYBOARD_KEY_CONNECTION = { | |
"!": ["`~", null, null, "2@", "qQ", null], | |
'"': [";:", "[{", "]}", null, null, "/?"], | |
"#": ["2@", null, null, "4\$", "eE", "wW"], | |
"\$": ["3#", null, null, "5%", "rR", "eE"], | |
"%": ["4\$", null, null, "6^", "tT", "rR"], | |
"&": ["6^", null, null, "8*", "uU", "yY"], | |
"'": [";:", "[{", "]}", null, null, "/?"], | |
"(": ["8*", null, null, "0)", "oO", "iI"], | |
")": ["9(", null, null, "-_", "pP", "oO"], | |
"*": ["7&", null, null, "9(", "iI", "uU"], | |
"+": ["-_", null, null, null, "]}", "[{"], | |
",": ["mM", "kK", "lL", ".>", null, null], | |
"-": ["0)", null, null, "=+", "[{", "pP"], | |
".": [",<", "lL", ";:", "/?", null, null], | |
"/": [".>", ";:", "'\"", null, null, null], | |
"0": ["9(", null, null, "-_", "pP", "oO"], | |
1: ["`~", null, null, "2@", "qQ", null], | |
2: ["1!", null, null, "3#", "wW", "qQ"], | |
3: ["2@", null, null, "4\$", "eE", "wW"], | |
4: ["3#", null, null, "5%", "rR", "eE"], | |
5: ["4\$", null, null, "6^", "tT", "rR"], | |
6: ["5%", null, null, "7&", "yY", "tT"], | |
7: ["6^", null, null, "8*", "uU", "yY"], | |
8: ["7&", null, null, "9(", "iI", "uU"], | |
9: ["8*", null, null, "0)", "oO", "iI"], | |
":": "lL,pP,[{,'\",/?,.>".split(","), | |
";": "lL,pP,[{,'\",/?,.>".split(","), | |
"<": ["mM", "kK", "lL", ".>", null, null], | |
"=": ["-_", null, null, null, "]}", "[{"], | |
">": [",<", "lL", ";:", "/?", null, null], | |
"?": [".>", ";:", "'\"", null, null, null], | |
"@": ["1!", null, null, "3#", | |
"wW", "qQ" | |
], | |
"A": [null, "qQ", "wW", "sS", "zZ", null], | |
"B": ["vV", "gG", "hH", "nN", null, null], | |
"C": ["xX", "dD", "fF", "vV", null, null], | |
"D": "sS,eE,rR,fF,cC,xX".split(","), | |
"E": "wW,3#,4\$,rR,dD,sS".split(","), | |
"F": "dD,rR,tT,gG,vV,cC".split(","), | |
"G": "fF,tT,yY,hH,bB,vV".split(","), | |
"H": "gG,yY,uU,jJ,nN,bB".split(","), | |
"I": "uU,8*,9(,oO,kK,jJ".split(","), | |
"J": "hH,uU,iI,kK,mM,nN".split(","), | |
"K": "jJ iI oO lL ,< mM".split(" "), | |
"L": "kK oO pP ;: .> ,<".split(" "), | |
"M": ["nN", "jJ", "kK", ",<", null, null], | |
"N": ["bB", "hH", "jJ", "mM", null, null], | |
"O": "iI,9(,0),pP,lL,kK".split(","), | |
"P": "oO,0),-_,[{,;:,lL".split(","), | |
"Q": [null, "1!", "2@", "wW", "aA", null], | |
"R": "eE,4\$,5%,tT,fF,dD".split(","), | |
"S": "aA,wW,eE,dD,xX,zZ".split(","), | |
"T": "rR,5%,6^,yY,gG,fF".split(","), | |
"U": "yY,7&,8*,iI,jJ,hH".split(","), | |
"V": ["cC", "fF", "gG", "bB", null, null], | |
"W": "qQ,2@,3#,eE,sS,aA".split(","), | |
"X": ["zZ", "sS", "dD", "cC", null, null], | |
"Y": "tT,6^,7&,uU,hH,gG".split(","), | |
"Z": [null, "aA", "sS", "xX", null, null], | |
"[": "pP,-_,=+,]},'\",;:".split(","), | |
"\\": ["]}", null, null, null, null, null], | |
"]": ["[{", "=+", null, "\\|", null, "'\""], | |
"^": ["5%", null, null, "7&", "yY", "tT"], | |
"_": ["0)", null, null, "=+", "[{", "pP"], | |
"`": [null, null, null, "1!", null, null], | |
"a": [null, "qQ", "wW", "sS", "zZ", null], | |
"b": ["vV", "gG", "hH", "nN", null, null], | |
"c": ["xX", "dD", "fF", "vV", null, null], | |
"d": "sS,eE,rR,fF,cC,xX".split(","), | |
"e": "wW,3#,4\$,rR,dD,sS".split(","), | |
"f": "dD,rR,tT,gG,vV,cC".split(","), | |
"g": "fF,tT,yY,hH,bB,vV".split(","), | |
"h": "gG,yY,uU,jJ,nN,bB".split(","), | |
"i": "uU,8*,9(,oO,kK,jJ".split(","), | |
"j": "hH,uU,iI,kK,mM,nN".split(","), | |
"k": "jJ iI oO lL ,< mM".split(" "), | |
"l": "kK oO pP ;: .> ,<".split(" "), | |
"m": ["nN", "jJ", "kK", ",<", null, null], | |
"n": ["bB", "hH", "jJ", "mM", null, null], | |
"o": "iI,9(,0),pP,lL,kK".split(","), | |
"p": "oO,0),-_,[{,;:,lL".split(","), | |
"q": [null, "1!", "2@", "wW", "aA", null], | |
"r": "eE,4\$,5%,tT,fF,dD".split(","), | |
"s": "aA,wW,eE,dD,xX,zZ".split(","), | |
"t": "rR,5%,6^,yY,gG,fF".split(","), | |
"u": "yY,7&,8*,iI,jJ,hH".split(","), | |
"v": ["cC", "fF", "gG", "bB", null, null], | |
"w": "qQ,2@,3#,eE,sS,aA".split(","), | |
"x": ["zZ", "sS", "dD", "cC", null, null], | |
"y": "tT,6^,7&,uU,hH,gG".split(","), | |
"z": [null, "aA", "sS", "xX", null, null], | |
"{": "pP,-_,=+,]},'\",;:".split(","), | |
"|": ["]}", null, null, null, null, null], | |
"}": ["[{", "=+", null, "\\|", null, "'\""], | |
"~": [null, null, null, "1!", null, null] | |
}; | |
Map<String, List<String>> _DICT_KEYBOARD_NUMBER_CONNECTION = { | |
"*": ["/", null, null, null, "-", "+", "9", "8"], | |
"+": ["9", "*", "-", null, null, null, null, "6"], | |
"-": ["*", null, null, null, null, null, "+", "9"], | |
".": ["0", "2", "3", null, null, null, null, null], | |
"/": [null, null, null, null, "*", "9", "8", "7"], | |
"0": [null, "1", "2", "3", ".", null, null, null], | |
1: [null, null, "4", "5", "2", "0", null, null], | |
2: ["1", "4", "5", "6", "3", ".", "0", null], | |
3: ["2", "5", "6", null, null, null, ".", "0"], | |
4: [null, null, "7", "8", "5", "2", "1", null], | |
5: "4,7,8,9,6,3,2,1".split(","), | |
6: ["5", "8", "9", "+", null, null, "3", "2"], | |
7: [null, null, null, "/", "8", "5", "4", null], | |
8: ["7", null, "/", "*", "9", "6", "5", "4"], | |
9: ["8", "/", "*", "-", "+", null, "6", "5"] | |
}; | |
void main() { | |
// Find keys next to "Q.w.E.R.T.Y.!" according to a physical layout of the keyboard. | |
"QwERTY!".codeUnits.forEach((int keyCode) { | |
var key = new String.fromCharCode(keyCode); | |
final List<String> nextKeys = _DICT_KEYBOARD_KEY_CONNECTION[key]; | |
if (nextKeys != null) | |
nextKeys.forEach((String nk) { | |
if (nk != null) | |
print("$key => $nk"); | |
}); | |
}); | |
} |
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
Q => 1! | |
Q => 2@ | |
Q => wW | |
Q => aA | |
w => qQ | |
w => 2@ | |
w => 3# | |
w => eE | |
w => sS | |
w => aA | |
E => wW | |
E => 3# | |
E => 4$ | |
E => rR | |
E => dD | |
E => sS | |
R => eE | |
R => 4$ | |
R => 5% | |
R => tT | |
R => fF | |
R => dD | |
T => rR | |
T => 5% | |
T => 6^ | |
T => yY | |
T => gG | |
T => fF | |
Y => tT | |
Y => 6^ | |
Y => 7& | |
Y => uU | |
Y => hH | |
Y => gG | |
! => `~ | |
! => 2@ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment