Skip to content

Key monitoring #525

Answered by ronf
RonDingDing asked this question in Q&A
Nov 14, 2022 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

The first thing you'll need to do is to request a PTY on the SSH session where you want this. This can be done by setting the "term_type" argument on the session where you want this. Doing so will disable local echo and buffering and local editing on the client. Once you've got that, you can call something like process.stdin.read(1) to have it return input a byte at a time. This won't correspond directly to "key presses", though, as some keys send a sequence of bytes. Since different keys can start off with the same subset of bytes, you need to keep reading until you have enough to distinguish one key from another before you act on it. The built-in line editor in AsyncSSH has the ability …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@RonDingDing
Comment options

@RonDingDing
Comment options

@RonDingDing
Comment options

@ronf
Comment options

@RonDingDing
Comment options

Answer selected by ronf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants