This post introduces a key presser on Linux with xvkb. But how to simulate pressing multiple keys together on Linux?
这篇文章介绍了使用xvkb在Linux上的按键。 但是如何在Linux上模拟同时按下多个键?
That is, I would like to have multiple keys such as “A” “B” “C” “D” pressed together and being hold. How to simulate this on Linux with programs/commands?
也就是说,我想按住多个键,例如“ A”,“ B”,“ C”,“ D”。 如何在Linux上使用程序/命令对此进行仿真?
You can make use of xdotool
(xdotool: command-line X11 automation tool) to simulate the keyboard pressing.
您可以使用xdotool
( xdotool:命令行X11自动化工具 )来模拟键盘按下。
The command for pressing ABCD together will be:
一起按下ABCD的命令将是:
xdotool sleep 5 keydown a keydown b keydown c keydown d
It will first sleep 5 seconds for you to click to focus on the target program’s window. Then it will press down a b c and d (not release them anymore).
首先将Hibernate5秒钟,以便您单击以聚焦在目标程序的窗口上。 然后它将按下abc和d(不再释放它们)。
After you would like to release these keys. Just kill the xdotool
instance by pressing Ctrl-C in the terminal.
之后您想释放这些键。 只需在终端中按Ctrl-C杀死xdotool
实例。
Note: you will need to press abcd once again more on your keyboard to actually release these keys.
注意:您将需要再次在键盘上再次按abcd才能释放这些键。
翻译自: https://www.systutorials.com/how-to-simulate-pressing-multiple-keys-together-on-linux/