如何在Linux上模拟同时按下多个键?

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.

您可以使用xdotoolxdotool:命令行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才能释放这些键。

Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。

翻译自: https://www.systutorials.com/how-to-simulate-pressing-multiple-keys-together-on-linux/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值