MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / handleKeyboardNavigation

Function handleKeyboardNavigation

codeclash/viewer/static/js/picker.js:684–730  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

682}
683
684function handleKeyboardNavigation(event) {
685 // Don't handle keyboard navigation if a dialog is open or input is focused
686 const modal = document.getElementById("bulk-actions-modal");
687 const modelDropdown = document.getElementById("model-filter-options");
688 if (
689 (modal && modal.style.display === "flex") ||
690 (modelDropdown && modelDropdown.style.display === "block") ||
691 document.activeElement.tagName === "INPUT" ||
692 document.activeElement.tagName === "SELECT"
693 ) {
694 return;
695 }
696
697 // Don't handle if no navigable rows
698 if (allNavigableRows.length === 0) {
699 return;
700 }
701
702 let handled = false;
703
704 switch (event.key) {
705 case "ArrowUp":
706 case "k":
707 event.preventDefault();
708 navigateUp();
709 handled = true;
710 break;
711
712 case "ArrowDown":
713 case "j":
714 event.preventDefault();
715 navigateDown();
716 handled = true;
717 break;
718
719 case "Enter":
720 event.preventDefault();
721 activateSelectedRow();
722 handled = true;
723 break;
724 }
725
726 if (handled) {
727 // Update navigable rows in case visibility changed
728 updateNavigableRows();
729 }
730}
731
732function navigateUp() {
733 if (currentSelectedIndex > 0) {

Callers

nothing calls this directly

Calls 4

navigateUpFunction · 0.85
navigateDownFunction · 0.85
activateSelectedRowFunction · 0.85
updateNavigableRowsFunction · 0.85

Tested by

no test coverage detected