MCPcopy
hub / github.com/wavetermdev/waveterm / appHandleKeyDown

Function appHandleKeyDown

frontend/app/store/keymodel.ts:416–468  ·  view source on GitHub ↗
(waveEvent: WaveKeyboardEvent)

Source from the content-addressed store, hash-verified

414}
415
416function appHandleKeyDown(waveEvent: WaveKeyboardEvent): boolean {
417 if (globalKeybindingsDisabled) {
418 return false;
419 }
420 const nativeEvent = (waveEvent as any).nativeEvent;
421 if (lastHandledEvent != null && nativeEvent != null && lastHandledEvent === nativeEvent) {
422 return false;
423 }
424 lastHandledEvent = nativeEvent;
425 if (activeChord) {
426 console.log("handle activeChord", activeChord);
427 // If we're in chord mode, look for the second key.
428 const chordBindings = globalChordMap.get(activeChord);
429 const [, handler] = checkKeyMap(waveEvent, chordBindings);
430 if (handler) {
431 resetChord();
432 return handler(waveEvent);
433 } else {
434 // invalid chord; reset state and consume key
435 resetChord();
436 return true;
437 }
438 }
439 const [chordKeyMatch] = checkKeyMap(waveEvent, globalChordMap);
440 if (chordKeyMatch) {
441 setActiveChord(chordKeyMatch);
442 return true;
443 }
444
445 const [, globalHandler] = checkKeyMap(waveEvent, globalKeyMap);
446 if (globalHandler) {
447 const handled = globalHandler(waveEvent);
448 if (handled) {
449 return true;
450 }
451 }
452 if (isTabWindow()) {
453 const layoutModel = getLayoutModelForStaticTab();
454 const focusedNode = globalStore.get(layoutModel.focusedNode);
455 const blockId = focusedNode?.data?.blockId;
456 if (blockId != null && shouldDispatchToBlock(waveEvent)) {
457 const bcm = getBlockComponentModel(blockId);
458 const viewModel = bcm?.viewModel;
459 if (viewModel?.keyDownHandler) {
460 const handledByBlock = viewModel.keyDownHandler(waveEvent);
461 if (handledByBlock) {
462 return true;
463 }
464 }
465 }
466 }
467 return false;
468}
469
470function registerControlShiftStateUpdateHandler() {
471 getApi().onControlShiftStateUpdate((state: boolean) => {

Callers 3

handleTerminalKeydownMethod · 0.90
tryReinjectKeyFunction · 0.85

Calls 9

isTabWindowFunction · 0.90
getBlockComponentModelFunction · 0.90
checkKeyMapFunction · 0.85
resetChordFunction · 0.85
setActiveChordFunction · 0.85
shouldDispatchToBlockFunction · 0.85
getMethod · 0.80
keyDownHandlerMethod · 0.45

Tested by

no test coverage detected