-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adding SendKey to Terminal #3578
Conversation
…irst step away from deprecated keyPress and hard key codes)
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.
I'm not really understanding this change, is there an issue tracking the problem? Also, it seems to be duplicating a lot of what happens in Keyboard.ts which causes bloat/tech debt and it's handling some keys differently:
No there is no exact issue tracking the problem except partially #1862. Keypress event (actually only space handled there?) and hard keyCodes are deprecated and will break things in the future. In fact those handlers could be implemented and tested with regular javascript beforehand this way. KeyPress https://developer.mozilla.org/en-US/docs/Web/API/Document/keypress_event Thought maybe someone can use this, Regards |
Thanks for the context. This sort of API could be valuable as I know some mobile terminals have shortcuts for ctrl+c/tab for example. I think the better approach would adapting the existing Keyboard.ts to work on Also, could the major case here be handled by |
"..adapting the existing Keyboard.ts to work on key.." With a SendKey function on the other hand all this could be tried out using vanilla javascript with zero installation overhead. All thats needed is a second test input/textarea plus the dom events to get the keys (String) and then a call to SendKey. If this would prove to be working it could be moved if not it could be taken out again. As far as my research goes handling events from device on screen keyboards should be done in beforeinput. beforeinput https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event pseudocode:
|
The overhead in this PR is the duplicated code which increases the size of the library. I still understand the difficulty in adapting this function to move away from xterm.js/src/common/input/Keyboard.ts Lines 38 to 43 in 82f8e06
|
beforeinput is like input but before editable content changes, since you are using input.. https://bugs.chromium.org/p/chromium/issues/detail?id=118639 (not actually a bug just the way things are now) For touch devices the only way to reliably use a browser terminal is to create a custom html/svg keyboard in the page itself (PWA/fullscreen) and then send keys yourself. This is where "sendKey" comes in handy for me. Since I don't think a mac meta key is really needed for that, it is left out. (only mac can selectAll?/does a normal terminal do this at all (ctrl+a)? is selectAll only there to support macmeta+a..?) closing this on my end for now - thank you for your time |
@A-J-Bauer thanks for the PR, I created an issue out of it as it seems valuable #3581. Someone else might pick it up |
I am also looking for an API like SendKey to deal with virtual keyboard with specialized shortcuts (for vim/nginx/lxc, etc) on mobile phone for handy server maintainance. With SendKey it would be convenient to connect customized keyboards to this. Or are there existing APIs for this case? (sending key events to xterm.js or execute a command) |
Any progress on this issue? |
For custom HTML on screen keyboards and as a first step away from deprecated keyPress and hard key codes.
(For built in touch-device on-screen-keyboards a beforeinput event handler could call this, for desktop a keydown event handler)