MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / keyPressed

Function keyPressed

static/scripts/markitup/jquery.markitup.js:483–527  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

481
482 // set keys pressed
483 function keyPressed(e) {
484 shiftKey = e.shiftKey;
485 altKey = e.altKey;
486 ctrlKey = (!(e.altKey && e.ctrlKey)) ? e.ctrlKey : false;
487
488 if (e.type === 'keydown') {
489 if (ctrlKey === true) {
490 li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li');
491 if (li.length !== 0) {
492 ctrlKey = false;
493 li.triggerHandler('mouseup');
494 return false;
495 }
496 }
497 if (e.keyCode === 13 || e.keyCode === 10) { // Enter key
498 if (ctrlKey === true) { // Enter + Ctrl
499 ctrlKey = false;
500 markup(options.onCtrlEnter);
501 return options.onCtrlEnter.keepDefault;
502 } else if (shiftKey === true) { // Enter + Shift
503 shiftKey = false;
504 markup(options.onShiftEnter);
505 return options.onShiftEnter.keepDefault;
506 } else { // only Enter
507 markup(options.onEnter);
508 return options.onEnter.keepDefault;
509 }
510 }
511 if (e.keyCode === 9) { // Tab key
512 if (shiftKey == true || ctrlKey == true || altKey == true) { // Thx Dr Floob.
513 return false;
514 }
515 if (caretOffset !== -1) {
516 get();
517 caretOffset = $$.val().length - caretOffset;
518 set(caretOffset, 0);
519 caretOffset = -1;
520 return false;
521 } else {
522 markup(options.onTab);
523 return options.onTab.keepDefault;
524 }
525 }
526 }
527 }
528
529 init();
530 });

Callers

nothing calls this directly

Calls 3

markupFunction · 0.85
getFunction · 0.70
setFunction · 0.70

Tested by

no test coverage detected