Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/core/KeyboardShortcutManager.js
| Show All 26 Lines | statics : { | ||||
| */ | */ | ||||
| _downkeys : { | _downkeys : { | ||||
| left: 1, | left: 1, | ||||
| right: 1, | right: 1, | ||||
| up: 1, | up: 1, | ||||
| down: 1 | down: 1 | ||||
| }, | }, | ||||
| /** | |||||
| * Some keys require Alt to be pressed in order to type them on certain | |||||
| * keyboard layouts. | |||||
| */ | |||||
| _altkeys: { | |||||
| // "Alt+L" on German layouts. | |||||
| '@': 1, | |||||
| // "Alt+Shift+7" on German layouts. | |||||
| '\\': 1 | |||||
| }, | |||||
| getInstance : function() { | getInstance : function() { | ||||
| if (!JX.KeyboardShortcutManager._instance) { | if (!JX.KeyboardShortcutManager._instance) { | ||||
| JX.KeyboardShortcutManager._instance = new JX.KeyboardShortcutManager(); | JX.KeyboardShortcutManager._instance = new JX.KeyboardShortcutManager(); | ||||
| } | } | ||||
| return JX.KeyboardShortcutManager._instance; | return JX.KeyboardShortcutManager._instance; | ||||
| } | } | ||||
| }, | }, | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | _clearReticle : function() { | ||||
| this._focusReticle = null; | this._focusReticle = null; | ||||
| }, | }, | ||||
| _onkeypress : function(e) { | _onkeypress : function(e) { | ||||
| if (!(this._getKey(e) in JX.KeyboardShortcutManager._downkeys)) { | if (!(this._getKey(e) in JX.KeyboardShortcutManager._downkeys)) { | ||||
| this._onkeyhit(e); | this._onkeyhit(e); | ||||
| } | } | ||||
| }, | }, | ||||
| _onkeyhit : function(e) { | _onkeyhit : function(e) { | ||||
| var self = JX.KeyboardShortcutManager; | |||||
| var raw = e.getRawEvent(); | var raw = e.getRawEvent(); | ||||
| if (raw.altKey || raw.ctrlKey || raw.metaKey) { | if (raw.ctrlKey || raw.metaKey) { | ||||
| // Never activate keyboard shortcuts if modifier keys are also | // Never activate keyboard shortcuts if modifier keys are also | ||||
| // depressed. | // depressed. | ||||
| return; | return; | ||||
| } | } | ||||
| // For most keystrokes, don't activate keyboard shortcuts if the Alt | |||||
| // key is depressed. However, we continue if the character requires the | |||||
| // use of Alt to type it on some keyboard layouts. | |||||
| var key = this._getKey(e); | |||||
| if (raw.altKey && !(key in self._altkeys)) { | |||||
| return; | |||||
| } | |||||
| var target = e.getTarget(); | var target = e.getTarget(); | ||||
| var ignore = ['input', 'select', 'textarea', 'object', 'embed']; | var ignore = ['input', 'select', 'textarea', 'object', 'embed']; | ||||
| if (JX.DOM.isType(target, ignore)) { | if (JX.DOM.isType(target, ignore)) { | ||||
| // Never activate keyboard shortcuts if the user has some other control | // Never activate keyboard shortcuts if the user has some other control | ||||
| // focused. | // focused. | ||||
| return; | return; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines | |||||