1.调用GetAsyncKeyState()获取指定按键的状态,GetActiveKey()检索指定范围内的按键状态 2.调用keybd_event()可合成一次击键事件,通常两次击键事件间需要设定时间间隔 3.调用MapVirtualKey()获取指定按键的硬件扫描码,传入keybd_event()第二个参数就可以对DirectInput有效. Public Class ImitateKeyClass Private Declare Sub keybd_event Lib "user32&qu…
获取当前键盘按键,代码如下: using UnityEngine; using System.Collections; public class GetCurrentKey : MonoBehaviour { KeyCode currentKey; void Start () { currentKey = KeyCode.Space; } void OnGUI() { if (Input.anyKeyDown) { Event e = Event.current; if (e.isKey) {…