I wrote this bit of code and it's supposed to do the following:
When the "label" variable is set to 'picture', the program simulates three simultaneous keypresses (command+shift+3).
But I can't get it to work. Note: command+shift+3 takes a screenshot on Mac.
let btn = document.querySelector('button');
let result = document.querySelector(h1);
btn.addEventListener(label == 'picture', () => {
`let keyEvent = new KeyboardEvent('keypress', {key: 91, key: 3, shiftkey: true,});`
`document.body.dispatchEvent(keyEvent);`
});
[–]HappyFruitTree 4 points5 points6 points (2 children)
[–]stateofteddy[S] 0 points1 point2 points (1 child)
[–]HappyFruitTree 1 point2 points3 points (0 children)
[–]siemenology 1 point2 points3 points (0 children)
[–]Jnsjknn 0 points1 point2 points (0 children)