-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Enable sending input to the Terminal with a keybinding #3799
Comments
I could have sworn that we had an issue that was "I want to be able to send input to the Terminal with a keybinding" but it doesn't seem like we do. Congratulations! This is now that issue Previously mentioned (in #2046):
|
@zadjii-msft I can read your mind. 😏 |
This would also enable a decent workaround for #530 (remap SHIFT + ENTER to some symbol that can be read instead). That would be an excellent band-aid for PowerShell folks looking to migrate. |
+1 request for this feature. |
For those who desperately seek a solution/workaround to remap key bindings, powertoys has a module to do this. Not the most perfect solution (since the mapping is global to the OS, not just the terminal) and I'm sure there are equivalents out there (AHK for instance), nor can you enter arbitrary input (only map to another shortcut), but this will at least tide one over until terminal can support this natively. |
Just curious if there's any love for this issue and is tracked on some milestone? Seems like a fairly popular request/demand based on the various dupes. Thanks, and much gratitude to WT - my daily driver. |
Alas! We haven't been working on this one, but we're pretty keen on it. I'm moving it into the 2.0 milestone and out of the backlog. I don't know if I believe that a spec is required beyond a paragraph explaining what |
No real commitments on this one quite yet. I especially want to do this for it's potential integration with the command palette (#5400). The hardest part of this is honestly just designing exactly how the setting should work. How will arrow keys be encoded in the settings file? Trailing newlines? etc. The implementation itself should be fairly trivial |
Wonder if it's an option to specify a sequence/string of characters bound to a key shortcut. User can input the escape sequence for the key they want to enter. For example, left arrrow will be Just a thought, not sure how useful. |
I'd like to implement this feature, if you don't mind. 🙂 I believe this feature is crucial, but realistically will probably only be used by a small fraction of all Windows Terminal users. ConfigI imagine a potential config setting to look like the following: {
"keybindings":
[
// Bind Ctrl+Shift+C to the Delete key
{ "keys": "ctrl+shift+c", "command": { "action": "sendInput", "input": "\u007f" } },
// Send some text when pressing F12
{ "keys": "f12", "command": { "action": "sendInput", "input": "text entered over and over again\n" } },
// Swap left/right arrow keys (lol)
{ "keys": "left", "command": { "action": "sendInput", "input": "\u001b[C" } },
{ "keys": "right", "command": { "action": "sendInput", "input": "\u001b[D" } },
// Send a VK_PLAY (media play/pause button) key press to your shell
{ "keys": "f11", "command": { "action": "sendInput", "input": "\u001b[250;0;0;1;0;1_\u001b[250;0;0;0;0;1_" } },
]
} Unfortunately I don't have a solution for CtrlBreak as that's equivalent to calling Implementation
Future extensionThe above solution is very technical, but IMO sufficient for an initial implementation and can still be extended later on. |
Thoughts off the top of the dome:
void TerminalPage::_HandleSendInput(const IInspectable& /*sender*/,
const TerminalApp::ActionEventArgs& args)
{
if (const auto& realArgs = args.ActionArgs().try_as<TerminalApp::SendInputArgs>())
{
const auto termControl = _GetActiveControl();
args.Handled(termControl.SendInput(realArgs.Input()));
}
} The implementation of I'm totally on board with this, thanks for the writeup! I'll throw you on the Assigned To line 😉 |
Aww... I always thought WT uses JSON5, but it seems it's using JSONC. (JSON5 supports Thanks @zadjii-msft! I wasn't aware about |
## Summary of the Pull Request This PR enables users to send arbitrary text input to the shell via a keybinding. ## PR Checklist * [x] Closes #3799 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [x] Schema updated. * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #3799 ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed Added the following keybindings: ```json { "keys": "p", "command": { "action": "sendInput", "input": "foobar" } }, { "keys": "q", "command": { "action": "sendInput", "input": "\u001b[A" } }, ``` Ensured that when pressing <kbd>P</kbd> "foobar" is echoed to the shell and when pressing <kbd>Q</kbd> the shell history is being navigated backwards.
🎉This issue was addressed in #7249, which has now been successfully released as Handy links: |
Description of the new feature/enhancement
On Windows, there are difference between CTRL + C and CTRL + BREAK, as mentioned in #1118.
Some keyboard layouts do not have the BREAK key. For example, on Surface keyboard, there are no BREAK key. In some situations, CTRL + BREAK is a crucial way to break some processes.
Will be great if Windows Terminal has a command to map CTRL + BREAK to some other keys, e.g. CTRL + SHIFT + BREAK.
Proposed technical implementation details (optional)
The text was updated successfully, but these errors were encountered: