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