Keyboard.releaseAll()
描述
放开所有已按着(请参考 Keyboard.press())的键盘按键。
语法
Keyboard.releaseAll();
参数
回传
无回传值
范例
// 在 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.releaseAll();
  // 等待新的分页开启
  delay(1000);
}
See also
- Keyboard.begin()
- Keyboard.end()
- Keyboard.press()
- Keyboard.print()
- Keyboard.println()
- Keyboard.release()
- 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.
