added ability to use actual letters or key names as keys in config...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-03-02 19:57:26 +04:00
parent e03430b5c9
commit b23bdeda49

View File

@ -40,11 +40,16 @@ function toKeyName(code){
// chars...
k = String.fromCharCode(code)
if(k != ''){
return k.toLowerCase()
//return k.toLowerCase()
return k
}
return null
}
function chr(c){
return c.charCodeAt(0)
}
// if set to false the event handlers will always return false...
var KEYBOARD_HANDLER_PROPAGATE = true
@ -89,6 +94,7 @@ function makeKeyboardHandler(keybindings, unhandled){
var bindings = keybindings[mode]
var key = evt.keyCode
var chr = toKeyName(evt.keyCode)
if(bindings.ignore == '*'
|| bindings.ignore != null && bindings.ignore.indexOf(key) != -1){
// return true
@ -101,7 +107,11 @@ function makeKeyboardHandler(keybindings, unhandled){
modifers += evt.altKey ? (modifers != '' ? '+alt' : 'alt') : ''
modifers += evt.shiftKey ? (modifers != '' ? '+shift' : 'shift') : ''
if(chr in bindings){
var handler = bindings[chr]
} else {
var handler = bindings[key]
}
// alias...
while (typeof(handler) == typeof(123)) {