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

27.27% Statements 3/11
25% Branches 1/4
100% Functions 1/1
33.33% Lines 3/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                        9x   9x 9x                                    
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);
 
  Eif (!activeTool) {
    return;
  }
 
  const { renderingEngineId, viewportId } = evt.detail;
 
  const toolGroup = ToolGroupManager.getToolGroupForViewport(
    viewportId,
    renderingEngineId
  );
 
  // Reset the modifier key
  resetModifierKey();
 
  const toolName = activeTool.getToolName();
  if (Object.keys(toolGroup.toolOptions).includes(toolName)) {
    toolGroup.setViewportsCursorByToolName(toolName);
  }
}