Index: branches/5.2.x/core/kernel/utility/debugger/debugger.js =================================================================== diff -u -N -r15130 -r15409 --- branches/5.2.x/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 15130) +++ branches/5.2.x/core/kernel/utility/debugger/debugger.js (.../debugger.js) (revision 15409) @@ -66,6 +66,7 @@ this.SQLTime = 0; this.ScriptTime = 0; this.ScriptMemory = 0; + this.Shortcut = 'F12'; for (var $param_name in $params) { this[$param_name] = $params[$param_name]; @@ -243,13 +244,102 @@ } Debugger.prototype.KeyDown = function($e) { - var $KeyCode = this.GetKeyCode($e); - if ($KeyCode == 123 || $KeyCode == 27) {// F12 or ESC + var $matched_parts = 0, + $KeyCode = this.GetKeyCode($e), + $shortcut_parts = this.Shortcut.toLowerCase().split('+'); + + $e = ($e) ? $e : event; + + var $modifier_map = { + 'ctrl': $e.ctrlKey, + 'shift': $e.shiftKey, + 'alt': $e.altKey, + 'meta': $e.metaKey + }; + + for (var $i = 0; $i < $shortcut_parts.length; $i++) { + for (var $modifier in $modifier_map) { + if ( $shortcut_parts[$i] == $modifier && $modifier_map[$modifier] ) { + $matched_parts++; + break; + } + } + + if ( this.getKeyCodeFromString($shortcut_parts[$i]) == $KeyCode ) { + $matched_parts++; + } + } + + if ( $matched_parts == $shortcut_parts.length || $KeyCode == 27 ) {// F12 or ESC this.Toggle($KeyCode); this.StopEvent($e); } } +Debugger.prototype.getKeyCodeFromString = function($string) { + var $special_keys = { + 'esc': 27, + 'escape': 27, + 'tab': 9, + 'space': 32, + 'return': 13, + 'enter': 13, + 'backspace': 8, + + 'scrolllock': 145, + 'scroll_lock': 145, + 'scroll': 145, + 'capslock': 20, + 'caps_lock': 20, + 'caps': 20, + 'numlock': 144, + 'num_lock': 144, + 'num': 144, + + 'pause': 19, + 'break': 19, + + 'insert': 45, + 'home': 36, + 'delete': 46, + 'end': 35, + + 'pageup': 33, + 'page_up': 33, + 'pu': 33, + + 'pagedown': 34, + 'page_down': 34, + 'pd': 34, + + 'left': 37, + 'up': 38, + 'right': 39, + 'down': 40, + + 'f1': 112, + 'f2': 113, + 'f3': 114, + 'f4': 115, + 'f5': 116, + 'f6': 117, + 'f7': 118, + 'f8': 119, + 'f9': 120, + 'f10': 121, + 'f11': 122, + 'f12': 123 + }; + + $string = $string.toLowerCase(); + + if ( $special_keys[$string] !== undefined ) { + return $special_keys[$string]; + } + + return $string.charCodeAt(0); +} + Debugger.prototype.OpenDOMViewer = function() { var $value = document.getElementById('dbg_domviewer').value; DOMViewerObj = ($value.indexOf('"') != -1) ? document.getElementById( $value.substring(1,$value.length-1) ) : eval($value); @@ -259,9 +349,14 @@ Debugger.prototype.GetKeyCode = function($e) { $e = ($e) ? $e : event; - var target = ($e.target) ? $e.target : $e.scrElement; var charCode = ($e.charCode) ? $e.charCode : (($e.which) ? $e.which : $e.keyCode); - return charCode; + + if ( charCode == 27 ) { + // don't lowercase ESC + return charCode; + } + + return String.fromCharCode(charCode).toLowerCase().charCodeAt(0); } Debugger.prototype.StopEvent = function($e) {