*/
handleKeyDown: function (inSender, inEvent) {
var that = this,
- keyCode = inEvent.keyCode;
+ keyCode = inEvent.keyCode,
+ exoticTransforms = {},
+ numberShiftCharacters = ")!@#$%^&*(";
- // XXX start hacks
- if (keyCode === 189) {
- // Dashes aren't coming through as dashes from my keyboard
- keyCode = '-'.charCodeAt(0);
- } else if (keyCode === 56 && inEvent.shiftKey) {
- // there's gotta be a way to know that shift-8 is *
- keyCode = '*'.charCodeAt(0);
+ // exotic transforms. sorta hackish, but the inEvent codes coming
+ // through are not always the ones we want
+
+ // http://stackoverflow.com/questions/1898129/javascript-subtract-keycode
+ exoticTransforms[XT.ASCII.VULGAR_HALF] = XT.ASCII.N_DASH;
+ if (_.contains(Object.keys(exoticTransforms), "" + keyCode)) {
+ // account for inexplicably wrongly mapped keys
+ keyCode = exoticTransforms[keyCode];
+ } else if (inEvent.shiftKey && keyCode >= XT.ASCII.ZERO && keyCode <= XT.ASCII.NINE) {
+ // shift-number should be transformed into the appropriate character
+ // XXX jingoistic implementation
+ keyCode = numberShiftCharacters.charCodeAt(keyCode - XT.ASCII.ZERO);
}
- // XXX end hacks
// remember the last 10 key presses
this._keyBufferArray.push(keyCode);