Huh, this doesn't seem to handle commas or semicolons at all. I can't immediately see why, since string.toUpperCase() maps "," to "," and ";" to ";", as it should. And switching input to
That's because the keydown event uses keyCode instead of charCode, and the two don't always match. Try typing Shift+U and then '[' on this page to see what I mean: http://unixpapa.com/js/testkey.html.
Since KeyboardJS is already loaded via requirejs, we can require it and then use it to get the keyCode for each character in the for loop.
var KeyboardJS = require('lib/keyboard');
[...]
for (var i = 0; i < input.length; ++i) {
var code = KeyboardJS.key.code(input.charAt(i));
if (code) {
soundArray.push(code);
} else {
soundArray.push(32);
}
}
I particularly like input = "qwdtytdwqertytreqxctntcxzxctbtvwqwdtytdwqertytreqxctntcxzxctbtvwqwdtytdwqertytreqxctntcxzxctbtvwqwdtytdwqertytreqxctntcxzxctbtvwqwdtytdwqertytreqxctntcxzxctbtvw"