MCPcopy Index your code
hub / github.com/adobe/react-spectrum / onKeyDown

Function onKeyDown

packages/react-aria/src/dnd/useDroppableCollection.ts:588–789  ·  view source on GitHub ↗
(e, drag)

Source from the content-addressed store, hash-verified

586 }
587 },
588 onKeyDown(e, drag) {
589 let {keyboardDelegate} = localState.props;
590 let types = getTypes(drag.items);
591 switch (e.key) {
592 case 'ArrowDown': {
593 if (keyboardDelegate.getKeyBelow) {
594 let target = nextValidTarget(
595 localState.state.target,
596 types,
597 drag.allowedDropOperations,
598 (target, wrap) => getNextTarget(target, wrap, 'down')
599 );
600 localState.state.setTarget(target);
601 }
602 break;
603 }
604 case 'ArrowUp': {
605 if (keyboardDelegate.getKeyAbove) {
606 let target = nextValidTarget(
607 localState.state.target,
608 types,
609 drag.allowedDropOperations,
610 (target, wrap) => getNextTarget(target, wrap, 'up')
611 );
612 localState.state.setTarget(target);
613 }
614 break;
615 }
616 case 'ArrowLeft': {
617 if (keyboardDelegate.getKeyLeftOf) {
618 let target = nextValidTarget(
619 localState.state.target,
620 types,
621 drag.allowedDropOperations,
622 (target, wrap) => getNextTarget(target, wrap, 'left')
623 );
624 localState.state.setTarget(target);
625 }
626 break;
627 }
628 case 'ArrowRight': {
629 if (keyboardDelegate.getKeyRightOf) {
630 let target = nextValidTarget(
631 localState.state.target,
632 types,
633 drag.allowedDropOperations,
634 (target, wrap) => getNextTarget(target, wrap, 'right')
635 );
636 localState.state.setTarget(target);
637 }
638 break;
639 }
640 case 'Home': {
641 if (keyboardDelegate.getFirstKey) {
642 let target = nextValidTarget(null, types, drag.allowedDropOperations, getNextTarget);
643 localState.state.setTarget(target);
644 }
645 break;

Callers

nothing calls this directly

Calls 11

getTypesFunction · 0.90
isInternalDropOperationFunction · 0.90
nextValidTargetFunction · 0.85
getNextTargetFunction · 0.85
setTargetMethod · 0.80
getDropOperationMethod · 0.80
onKeyDownMethod · 0.80
getFirstKeyMethod · 0.65
getKeyPageBelowMethod · 0.65
getLastKeyMethod · 0.65
getKeyPageAboveMethod · 0.65

Tested by

no test coverage detected