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

Function initUIEventModifiers

src/event/createEvent.ts:144–185  ·  view source on GitHub ↗
(
  event: KeyboardEvent | MouseEvent,
  {
    altKey,
    ctrlKey,
    metaKey,
    shiftKey,
    modifierAltGraph,
    modifierCapsLock,
    modifierFn,
    modifierFnLock,
    modifierNumLock,
    modifierScrollLock,
    modifierSymbol,
    modifierSymbolLock,
  }: EventModifierInit,
)

Source from the content-addressed store, hash-verified

142}
143
144function initUIEventModifiers(
145 event: KeyboardEvent | MouseEvent,
146 {
147 altKey,
148 ctrlKey,
149 metaKey,
150 shiftKey,
151 modifierAltGraph,
152 modifierCapsLock,
153 modifierFn,
154 modifierFnLock,
155 modifierNumLock,
156 modifierScrollLock,
157 modifierSymbol,
158 modifierSymbolLock,
159 }: EventModifierInit,
160) {
161 assignProps(event, {
162 altKey: Boolean(altKey),
163 ctrlKey: Boolean(ctrlKey),
164 metaKey: Boolean(metaKey),
165 shiftKey: Boolean(shiftKey),
166 getModifierState(k: string) {
167 return Boolean(
168 {
169 Alt: altKey,
170 AltGraph: modifierAltGraph,
171 CapsLock: modifierCapsLock,
172 Control: ctrlKey,
173 Fn: modifierFn,
174 FnLock: modifierFnLock,
175 Meta: metaKey,
176 NumLock: modifierNumLock,
177 ScrollLock: modifierScrollLock,
178 Shift: shiftKey,
179 Symbol: modifierSymbol,
180 SymbolLock: modifierSymbolLock,
181 }[k],
182 )
183 },
184 })
185}
186
187function initKeyboardEvent(
188 event: KeyboardEvent,

Callers

nothing calls this directly

Calls 1

assignPropsFunction · 0.85

Tested by

no test coverage detected