Skip to content
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

preventDefault for F5 - F8 and Backspace? #3

Closed
kunKun-tx opened this issue Aug 1, 2019 · 5 comments
Closed

preventDefault for F5 - F8 and Backspace? #3

kunKun-tx opened this issue Aug 1, 2019 · 5 comments

Comments

@kunKun-tx
Copy link

Maybe we shall add preventDefault() on F5 and Backspace and also map F5-F8 to keypad num keys?

@d07RiV
Copy link
Owner

d07RiV commented Aug 1, 2019

I'm not a fan of blocking all keyboard shortcuts but maybe this is the right time to do it. I'll put it in and see if it causes any issues.

@d07RiV
Copy link
Owner

d07RiV commented Aug 1, 2019

Okay, preventing default on all keypresses was a disaster. Limiting it to Backspace and F1/F5 for now.

What is the purpose for mapping F5-F8 to numpad?

@kunKun-tx
Copy link
Author

oh, didn't realize you prevent default on all keypresses. I wrote a tampermonkey script to prevent it only for f1, f5, and backspace and haven't have any issue.

F5-F8 were used as hotkey to switch skills. As you would suspect, only f6 and f8 work flawlessly, f5 will refresh the page and f7 will call out a firefox window.

@kunKun-tx
Copy link
Author

I tried using KeyboardEvent to remap F5-F8 w/o any success. I suspect it's not allowed for security reasons (see quote from MDN below). Besides, even if it works, it would still trigger as Browser's shortcut. Is there a way to change the key binding inside complied devilution wasm files? Numpad 1 - 4 will work well for this.

Manually firing an event does not generate the default action associated with that event. For example, manually firing a key event does not cause that letter to appear in a focused text input. In the case of UI events, this is important for security reasons, as it prevents scripts from simulating user actions that interact with the browser itself.

@d07RiV
Copy link
Owner

d07RiV commented Aug 1, 2019

Ah, right. Thought you meant mapping the other way. Extended it to F1-F8 plus backspace.

@d07RiV d07RiV closed this as completed Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants