简体   繁体   中英

Get keyboard scancode of char

I want to interact with a Virtualbox-VM to do an unattended install of Virtualbox-Guest-Additions. Therefore I have to send keystrokes to the VM. I'm able to do this by using the VBoxManage-API, where I send the HEX of the scancode to the VM:

# sends "b" to the VM
VBoxManage controlvm "$VMNAME" keyboardputscancode <HEX>

Now I want to send a complete command to the VM, like:

mount /dev/scd0 /media/cdrom0<Enter>

So I have to convert every single char of that string into a scancode and send it to the VM by using VBoxManage.

How do I convert these chars to the corresponding keyboard scancodes on Linux? My VM has the same keyboard mapping like my host. I'm looking for something I can use like that:

$ getscancode n
> 31

?

showkey --ascii似乎适用于大多数键 ,它确实在我的GNOME终端中工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM