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.