MCPcopy Create free account
hub / github.com/testing-library/user-event / getKeyEventProps

Function getKeyEventProps

src/keyboard/getEventProps.ts:3–18  ·  view source on GitHub ↗
(keyDef: keyboardKey, state: keyboardState)

Source from the content-addressed store, hash-verified

1import {keyboardKey, keyboardState} from './types'
2
3export function getKeyEventProps(keyDef: keyboardKey, state: keyboardState) {
4 return {
5 key: keyDef.key,
6 code: keyDef.code,
7 altKey: state.modifiers.alt,
8 ctrlKey: state.modifiers.ctrl,
9 metaKey: state.modifiers.meta,
10 shiftKey: state.modifiers.shift,
11
12 /** @deprecated use code instead */
13 keyCode:
14 keyDef.keyCode ??
15 // istanbul ignore next
16 (keyDef.key?.length === 1 ? keyDef.key.charCodeAt(0) : undefined),
17 }
18}
19
20export function getMouseEventProps(state: keyboardState) {
21 return {

Callers 4

keydownFunction · 0.90
keypressFunction · 0.90
keyupFunction · 0.90
functional.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected