import { omit } from '@remirror/core-helpers' ; import type { Shape } from '@remirror/core-types' ; import type { KeyboardEventName , ModifierInformation } from './test-keyboard-types' ; import { KeyDefinition , SupportedCharacters , usKeyboardLayout } from './us-keyboard-layout' ; param type param options export function createKeyboardEvent ( type , options ) { return new KeyboardEvent ( type , { ... options , bubbles : true } ) ; } interface GetModifierInformationProps { /**
     * The modifier keys passed in
     */ modifiers : string [ ] ; default isMac ? : boolean ; } param props export function getModifierInformation ( props ) { const { modifiers , isMac = false } = props ; const info = { altKey : false , ctrlKey : false , shiftKey : false , metaKey : false , } ; for ( const modifier of modifiers ) { if ( /^(cmd|meta|m)$/i . test ( modifier ) ) { info . metaKey = true ; } else if ( /^a(lt)?$/i . test ( modifier ) ) { info . altKey = true ; } else if ( /^(c|ctrl|control)$/i . test ( modifier ) ) { info . ctrlKey = true ; } else if ( /^s(hift)?$/i . test ( modifier ) ) { info . shiftKey = true ; } else if ( /^mod$/i . test ( modifier ) ) { if ( isMac ) { info . metaKey = true ; } else { info . ctrlKey = true ; } } else { throw new Error ( `Unrecognized modifier name: ${ modifier }` ) ; } } return info ; } param key export function cleanKey ( key ) { return omit ( usKeyboardLayout [ key ] , [ 'shiftKey' ] ) ; }