1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/packages/editor/CodeMirror/testUtil/pressReleaseKey.ts

21 lines
409 B
TypeScript
Raw Normal View History

import { EditorView } from '@codemirror/view';
interface KeyInfo {
key: string;
code: string;
ctrlKey?: boolean;
metaKey?: boolean;
shiftKey?: boolean;
}
const pressReleaseKey = (editor: EditorView, key: KeyInfo) => {
editor.contentDOM.dispatchEvent(
new KeyboardEvent('keydown', key),
);
editor.contentDOM.dispatchEvent(
new KeyboardEvent('keyup', key),
);
};
export default pressReleaseKey;