MCPcopy Create free account
hub / github.com/esengine/esengine / handleKeyDown

Function handleKeyDown

packages/editor-app/src/components/ContentBrowser.tsx:514–575  ·  view source on GitHub ↗
(e: KeyboardEvent)

Source from the content-addressed store, hash-verified

512 // 键盘快捷键处理 | Keyboard shortcuts handling
513 useEffect(() => {
514 const handleKeyDown = (e: KeyboardEvent) => {
515 // 如果正在输入或有对话框打开,不处理快捷键
516 // Skip shortcuts if typing or dialog is open
517 if (
518 e.target instanceof HTMLInputElement ||
519 e.target instanceof HTMLTextAreaElement ||
520 renameDialog ||
521 deleteConfirmDialog ||
522 createFileDialog
523 ) {
524 return;
525 }
526
527 // 只在内容浏览器区域处理快捷键
528 // Only handle shortcuts when content browser has focus
529 if (!containerRef.current?.contains(document.activeElement) &&
530 document.activeElement !== containerRef.current) {
531 return;
532 }
533
534 // F2 - 重命名 | Rename
535 if (e.key === 'F2' && selectedPaths.size === 1) {
536 e.preventDefault();
537 const selectedPath = Array.from(selectedPaths)[0];
538 const asset = assets.find(a => a.path === selectedPath);
539 if (asset) {
540 setRenameDialog({ asset, newName: asset.name });
541 }
542 }
543
544 // Delete - 删除 | Delete
545 if (e.key === 'Delete' && selectedPaths.size === 1) {
546 e.preventDefault();
547 const selectedPath = Array.from(selectedPaths)[0];
548 const asset = assets.find(a => a.path === selectedPath);
549 if (asset) {
550 setDeleteConfirmDialog(asset);
551 }
552 }
553
554 // Ctrl+A - 全选 | Select all
555 if (e.key === 'a' && (e.ctrlKey || e.metaKey)) {
556 e.preventDefault();
557 // 计算当前过滤后的资产 | Calculate currently filtered assets
558 const currentFiltered = searchQuery.trim()
559 ? assets.filter(a => a.name.toLowerCase().includes(searchQuery.toLowerCase()))
560 : assets;
561 const allPaths = new Set(currentFiltered.map(a => a.path));
562 setSelectedPaths(allPaths);
563 const lastItem = currentFiltered[currentFiltered.length - 1];
564 if (lastItem) {
565 setLastSelectedPath(lastItem.path);
566 }
567 }
568
569 // Escape - 取消选择 | Deselect all
570 if (e.key === 'Escape') {
571 e.preventDefault();

Callers

nothing calls this directly

Calls 5

filterMethod · 0.65
containsMethod · 0.45
fromMethod · 0.45
findMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected