All files / packages/tools/src/eventDispatchers/keyboardEventHandlers keyUp.ts

88.88% Statements 8/9
50% Branches 2/4
100% Functions 1/1
88.88% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                        12x   12x       12x   12x           12x   12x 12x 12x      
import { resetModifierKey } from '../../eventListeners/keyboard/keyDownListener';
import { ToolGroupManager } from '../../store';
import getActiveToolForKeyboardEvent from '../shared/getActiveToolForKeyboardEvent';
import { KeyDownEventType } from '../../types/EventTypes';
 
/**
 * KeyDown event listener to handle viewport cursor icon changes
 *
 * @param evt - The KeyboardEvent
 */
export default function keyUp(evt: KeyDownEventType): void {
  // get the active tool for the primary mouse button
  const activeTool = getActiveToolForKeyboardEvent(evt);
 
  Iif (!activeTool) {
    return;
  }
 
  const { renderingEngineId, viewportId } = evt.detail;
 
  const toolGroup = ToolGroupManager.getToolGroupForViewport(
    viewportId,
    renderingEngineId
  );
 
  // Reset the modifier key
  resetModifierKey();
 
  const toolName = activeTool.getToolName();
  Eif (Object.keys(toolGroup.toolOptions).includes(toolName)) {
    toolGroup.setViewportsCursorByToolName(toolName);
  }
}