MCPcopy Create free account
hub / github.com/sql-js/sql.js / dispatch

Function dispatch

documentation/javascript/application.js:10245–10287  ·  view source on GitHub ↗
(event, scope)

Source from the content-addressed store, hash-verified

10243
10244 // handle keydown event
10245 function dispatch(event, scope){
10246 var key, handler, k, i, modifiersMatch;
10247 key = event.keyCode;
10248
10249 // if a modifier key, set the key.<modifierkeyname> property to true and return
10250 if(key == 93 || key == 224) key = 91; // right command on webkit, command on Gecko
10251 if(key in _mods) {
10252 _mods[key] = true;
10253 // 'assignKey' from inside this closure is exported to window.key
10254 for(k in _MODIFIERS) if(_MODIFIERS[k] == key) assignKey[k] = true;
10255 return;
10256 }
10257
10258 // see if we need to ignore the keypress (ftiler() can can be overridden)
10259 // by default ignore key presses if a select, textarea, or input is focused
10260 if(!assignKey.filter.call(this, event)) return;
10261
10262 // abort if no potentially matching shortcuts found
10263 if (!(key in _handlers)) return;
10264
10265 // for each potential shortcut
10266 for (i = 0; i < _handlers[key].length; i++) {
10267 handler = _handlers[key][i];
10268
10269 // see if it's in the current scope
10270 if(handler.scope == scope || handler.scope == 'all'){
10271 // check if modifiers match if any
10272 modifiersMatch = handler.mods.length > 0;
10273 for(k in _mods)
10274 if((!_mods[k] && index(handler.mods, +k) > -1) ||
10275 (_mods[k] && index(handler.mods, +k) == -1)) modifiersMatch = false;
10276 // call the handler and stop the event if neccessary
10277 if((handler.mods.length == 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
10278 if(handler.method(event, handler)===false){
10279 if(event.preventDefault) event.preventDefault();
10280 else event.returnValue = false;
10281 if(event.stopPropagation) event.stopPropagation();
10282 if(event.cancelBubble) event.cancelBubble = true;
10283 }
10284 }
10285 }
10286 }
10287 };
10288
10289 // unset modifier keys on keyup
10290 function clearModifier(event){

Callers 1

application.jsFile · 0.85

Calls 1

indexFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…