I'm trying to simulate user keyboard input and have read through the answers for this post , but the answer(s) don't work for special keys such as $ . For example, when I try to simulate pressing $ with let data = { code: "Digit4", key: "$", keyCode: 52, shiftKey: true }; let key_event = new KeyboardEvent("keypress", data); myElement.dispatchEvent(key_event); 4 gets pressed/printed, not $ . If I change keypress to keydown or keyup, then nothing happens. What is the correct way to simulate the user pressing a special key like $ then? Also, I'm on Mac/Chrome if it matters Via Active questions tagged javascript - Stack Overflow https://ift.tt/ezcRE8X
A site where you can share knowledge