Skip to content

How to send a key to the pane? #15

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

Closed
niya3 opened this issue Oct 5, 2016 · 4 comments
Closed

How to send a key to the pane? #15

niya3 opened this issue Oct 5, 2016 · 4 comments
Labels

Comments

@niya3
Copy link

niya3 commented Oct 5, 2016

Works from terminal:
tmux send-key -t 0 Enter
->

user@host$
user@host$

Doesn't work in libtmux:

>>> import libtmux
>>> pane = libtmux.Server().get_by_id('$1').attached_pane
>>> pane
Pane(%5 Window(@4 2:a, Session($1 foo)))
>>> pane.send_keys('Enter')

->

user@host$  Enter
Enter: command not found

up. oh, #13 -_-

@tony
Copy link
Member

tony commented Oct 6, 2016

https://libtmux.readthedocs.io/api.html#libtmux.Pane.send_keys

What keys are you trying to send?

pane.send_keys('')

send_keys automatically sends enter, unless you do enter=False:

pane.send_keys('echo "Hi"', enter=False)

@niya3
Copy link
Author

niya3 commented Oct 7, 2016

I'm trying to send Enter, Up, Down, and other special keys.

man tmux

tmux allows a command to be bound to most keys, with or without a prefix
key. When specifying keys, most represent themselves (for example ‘A’ to
‘Z’). Ctrl keys may be prefixed with ‘C-’ or ‘^’, and Alt (meta) with
‘M-’. In addition, the following special key names are accepted: Up,
Down, Left, Right, BSpace, BTab, DC (Delete), End, Enter, Escape, F1 to
F20, Home, IC (Insert), NPage/PageDown/PgDn, PPage/PageUp/PgUp, Space,
and Tab.

@tony
Copy link
Member

tony commented Oct 7, 2016

Does pane.send_keys('') work to send Enter?

Also, you can try the other keys as well, does send_keys('Left', enter=False, suppress_history=False) work?

@stale
Copy link

stale bot commented Nov 11, 2017

This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.

This bot is used to handle issues where the issue hasn't been discussed or
has gone out of date. If an issue isn't resolved and handled in a certain
period of time, it may be closed. If you would like your issue re-opened,
please create a fresh issue with the latest, up to date information and
mention this issue in it.

@stale stale bot added the stale label Nov 11, 2017
@stale stale bot closed this as completed Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants