当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Arduino Keyboard.releaseAll()用法及代码示例


说明

放开当前按下的所有键。有关其他信息,请参阅Keyboard.press()

用法

Keyboard.releaseAll()

参数

None

返回

示例代码

#include <Keyboard.h>

// use this option for OSX:
char ctrlKey = KEY_LEFT_GUI;
// use this option for Windows and Linux:
//  char ctrlKey = KEY_LEFT_CTRL;

void setup() {
  // make pin 2 an input and turn on the
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(2, INPUT_PULLUP);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
  while (digitalRead(2) == HIGH) {
    // do nothing until pin 2 goes low
    delay(500);
  }
  delay(1000);
  // new document:
  Keyboard.press(ctrlKey);
  Keyboard.press('n');
  delay(100);
  Keyboard.releaseAll();
  // wait for new window to open:
  delay(1000);
}

相关用法


注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 Keyboard.releaseAll()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。