-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow holding key on mac to send multiple keys to terminal #1849
Conversation
@Tyriar I'm not sure what you mean. We agree that this code changes the behavior from popup showing -> sending multiple keys, right? Are you seeing the popup when using xterm.js? |
@Tyriar additionally, for me, the popup shows up only when using a text editor, but not when using the Terminal window. I would think that xterm.js should emulate the behavior of Terminal by not showing the popup. |
You're right, silly me didn't check actual terminals 😅 |
@mofux @jerch looks like this fixes it but it seems to make all the keypress code unnecessary. Do either of you know why keypress would be handled differently? It seems like it's been this way from the very beginning: https://github.com/chjj/term.js/blob/548af6e0a15c5978a2b62a882f7db03ec2ae2850/src/term.js#L2850 |
The difference between |
The key event handling dates back to the original impl from 2011. In those days it was a nightmare to get a somewhat reliable key handling across browsers and platforms. For many keys and combinations you would have to deal with both events due to a lack of specification (http://unixpapa.com/js/key.html). Not sure which event should be used these days, a summary can be found here https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode. |
I think we may need to use both keypress and keydown but in a different way -- as @mofux said, keypress only fires if the pressed key results in a character, so we can use that to detect if the key should result in a character (rather than the Additionally, instead of the logic that's there now, we should use https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key instead (and use a polyfill - https://github.com/cvan/keyboardevent-key-polyfill - if we need to support older browsers). Refactoring the code to do those is probably a separate issue unrelated to this one though, so I think we should merge this and then work on that issue. |
@Tyriar is this all set? Are there any changes you'd like to see before this PR can be merged? |
I just tried and that popup I mentioned earlier does appear now (I recently upgrades to Mojave): Even cancelling the event doesn't seem to stop this unfortunately 🙁 Also, I tried removing the keypress event on top of this change, but then space doesn't work. Created #1862 for moving to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this in, it doesn't seem likely that it'll cause issues after investigating a bit. Thanks @epicfaace 👍
This causes an issue on Linux when the |
Fixes #265 - Holding down a key only sends a single key on Mac
Also see microsoft/vscode#65436