MCPcopy
hub / github.com/tmcw/big / onKeyDown

Function onKeyDown

lib/big.js:419–462  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

417 }
418
419 function onKeyDown(e) {
420 if (big.mode === "talk") {
421 switch (e.key) {
422 case "ArrowLeft":
423 case "ArrowUp":
424 case "PageUp":
425 return reverse();
426 case "ArrowRight":
427 case "ArrowDown":
428 case "PageDown":
429 return forward();
430 }
431 }
432 switch (e.key) {
433 case "p":
434 onPrint();
435 break;
436 case "t":
437 onTalk();
438 break;
439 case "j":
440 onJump();
441 break;
442 }
443 if (big.mode === "jump") {
444 var activeElement = document.activeElement;
445 if (activeElement && activeElement.classList.contains("slide")) {
446 var column = [];
447 var startIndex = slideDivs.indexOf(activeElement.parentNode);
448 var columnIndexes = getColumnIndexes(activeElement);
449 jumpFocus(
450 e,
451 {
452 ArrowLeft: startIndex - 1,
453 ArrowRight: startIndex + 1,
454 ArrowDown: columnIndexes.next,
455 ArrowUp: columnIndexes.prev
456 }[e.key]
457 );
458 } else if (e.key.indexOf("Arrow") === 0) {
459 jumpFocus(e, 0);
460 }
461 }
462 }
463
464 function getColumnIndexes(activeElement) {
465 var left = activeElement.getBoundingClientRect().left;

Callers

nothing calls this directly

Calls 7

reverseFunction · 0.85
forwardFunction · 0.85
onPrintFunction · 0.85
onTalkFunction · 0.85
onJumpFunction · 0.85
getColumnIndexesFunction · 0.85
jumpFocusFunction · 0.85

Tested by

no test coverage detected