You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

31 lines
695 B

const keypress = (opts) => {
let event = new KeyboardEvent('keypress', {
key: opts.key,
altKey: opts.altKey,
shiftKey: opts.shiftKey,
ctrlKey: opts.ctrlKey
});
document.body.dispatchEvent(event);
};
const keydown = (opts) => {
let event = new KeyboardEvent('keydown', {
key: opts.key,
altKey: opts.altKey,
shiftKey: opts.shiftKey,
ctrlKey: opts.ctrlKey
});
document.body.dispatchEvent(event);
};
const keyup = (opts) => {
let event = new KeyboardEvent('keyup', {
key: opts.key,
altKey: opts.altKey,
shiftKey: opts.shiftKey,
ctrlKey: opts.ctrlKey
});
document.body.dispatchEvent(event);
};
export { keypress, keydown, keyup };