Home > OS >  No terminal interface under Linux how to obtain the keyboard characters
No terminal interface under Linux how to obtain the keyboard characters

Time:10-05

If open a terminal, to write the scanf () function demo, can obtain the keyboard type out of character, but if there is no end, C program should be how to get on the keyboard characters,
Currently know about is/dev/input/event * can monitor keyboard events, but print is input code, what I want is a string

CodePudding user response:

Continuous read, and it is the key value

CodePudding user response:

https://blog.csdn.net/qq_20553613/article/details/79216665#comments

CodePudding user response:

Your program is running in the background? If it is a daemon, to capture key, is likely to be more thorough understanding of the Linux kernel "input" input subsystem, or/dev/input/event handling,
Now you output the wrong data should be coding problem, need to input accordingly,

CodePudding user response:

For example, in a development version (no screen, through SSH terminal operation) plug in a usb keyboard), I need real-time monitoring program what characters, tapping the keyboard I know/dev/input/event * can monitor keyboard events, related code can also find on the net, I under a demo, knock down the Q button, printed is
 type: 4 code: the value of 16:0 
according to the input. H 16 is on behalf of the Q key can know, but I need the string, not plastic, have a way to put these plastic value converted to the corresponding string?
  • Related