mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
21 lines
409 B
TypeScript
21 lines
409 B
TypeScript
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;
|