當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino Keyboard.release()用法及代碼示例

說明

放開指定的鍵。有關詳細信息,請參閱Keyboard.press()

用法

Keyboard.release(key)

參數

key :釋放的關鍵。允許的數據類型:char

返回

釋放的鍵數。數據類型:size_t

示例代碼

#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.release(ctrlKey);
  Keyboard.release('n');
  // wait for new window to open:
  delay(1000);
}

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 Keyboard.release()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。