-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How are keyboard events sent to dosbox? #22
Comments
It's surprisingly difficult to get browsers to trigger a keyboard event. However, after consulting various answers on the topic, the following code was what I came up with to solve the problem. See if it works for you:
|
Thanks for the response! What is element in this case? I tried using document and it didn't work. |
Ah, good question! Here's the code I have that sets element:
Basically, it should be a reference to the element that DOSBox is rendering into. The code dispatches events onto that element so that they can be captured by DOSBox. |
Actually just using document also works! The trick is to send a keyup event shortly after a keydown event to simulate a keypress. Sending a keypress event directly doesn't work for some reason. Just sending keydown event also doesn't have the correct behavior, but I think I can work around that. Thanks! |
I want to create some buttons that can be clicked on, and when these buttons are clicked, I want to send keyboard events to dosbox. I can't find a place to add this logic. I tried adding window.onkeypress. I get events before dosbox is loaded, after it's loaded I don't get any events anymore. Can you point out where I should be looking at?
Thanks
The text was updated successfully, but these errors were encountered: