As @rioV8 hinted in the comments, you can do this with the workbench.action.terminal.sendSequence
keybinding command.
For official documentation, see https://code.visualstudio.com/docs/terminal/advanced#_custom-sequence-keybindings.
Here's a template of what it might look like in your keybindings.json file:
{
"key": "", // TODO put something here
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "r" }
}
Note: If the keybinding you want to use is already in use, I believe you need to explicitly disable it. You search for existing keybindings in the keybindings UI and then delete/disable them there.
Here's a bit more excerpt from the above linked docs:
This feature supports variable substitution.
The sendSequence
command only works with the \u0000
format for using characters via their character code (not \x00
). Read more about these hex codes and terminal sequences in the following resources: