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

Function initializeKeyboardShortcuts

codeclash/viewer/static/js/app.js:90–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88
89// Keyboard shortcuts
90function initializeKeyboardShortcuts() {
91 document.addEventListener("keydown", function (e) {
92 // Don't trigger shortcuts if user is typing in an input field
93 if (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA") {
94 return;
95 }
96
97 // h or Left Arrow: Navigate to previous game
98 if (e.key === "h" || e.key === "ArrowLeft") {
99 e.preventDefault();
100 navigateToPreviousGame();
101 return;
102 }
103
104 // l or Right Arrow: Navigate to next game
105 if (e.key === "l" || e.key === "ArrowRight") {
106 e.preventDefault();
107 navigateToNextGame();
108 return;
109 }
110
111 // p: Open game picker in same tab, P: Open game picker in new tab
112 if (e.key === "p") {
113 e.preventDefault();
114 openGamePicker();
115 return;
116 }
117
118 if (e.key === "P") {
119 e.preventDefault();
120 openGamePickerInNewTab();
121 return;
122 }
123
124 // t/T: Toggle TOC menu visibility
125 if (e.key === "t" || e.key === "T") {
126 e.preventDefault();
127 toggleTocMenu();
128 return;
129 }
130
131 // ?: Show help modal
132 if (e.key === "?") {
133 e.preventDefault();
134 showHelpModal();
135 return;
136 }
137
138 // Escape: Close all open details
139 if (e.key === "Escape") {
140 const openDetails = document.querySelectorAll("details[open]");
141 openDetails.forEach((details) => {
142 details.removeAttribute("open");
143 });
144 return;
145 }
146
147 // Ctrl/Cmd + E: Expand all details

Callers 1

app.jsFile · 0.85

Calls 6

navigateToPreviousGameFunction · 0.85
navigateToNextGameFunction · 0.85
openGamePickerFunction · 0.85
openGamePickerInNewTabFunction · 0.85
toggleTocMenuFunction · 0.85
showHelpModalFunction · 0.85

Tested by

no test coverage detected