Keyboard.release()
描述
放开一个已被按下(请参考 Keyboard.press())的键盘按键。
语法
Keyboard.release(key);
参数
key:要放开哪一个键盘按键 char 型别
回传
无回传值
范例
// 在 OSX 系统中使用的 ctrl 按键:
char ctrlKey = KEY_LEFT_GUI;
// 在 Windows 或 Linux 下使用的 ctrl 按键:
// char ctrlKey = KEY_LEFT_CTRL;
void setup() {
// 将 pin 2 设定为 INPUT_PULLUP 状态
// 这样它就会在外部按钮被按下时
// 呈现 LOW 的状态
pinMode(2, INPUT_PULLUP);
// 开始 HID 键盘模拟
Keyboard.begin();
}
void loop() {
while (digitalRead(2) == HIGH) {
// 不做任何事情直到 pin 2 为 LOW
delay(500);
}
delay(1000);
// 在 IDE 上打开新的分页
Keyboard.press(ctrlKey);
Keyboard.press('n');
delay(100);
Keyboard.release(ctrlKey);
Keyboard.release('n');
// 等待新的分页开启
delay(1000);
}
See also
- Keyboard.begin()
- Keyboard.end()
- Keyboard.press()
- Keyboard.print()
- Keyboard.println()
- Keyboard.releaseAll()
- Keyboard.write()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
