Keyboard.begin()

描述

初始化 HID 鍵盤。begin()要在尚未呼叫任何鍵盤控制函式前呼叫。
要結束 HID 鍵盤的模擬行為,必需呼叫 Keyboard.end()

語法


Keyboard.begin()

參數

回傳

無回傳值

範例

void setup(){
  // 將 pin 2 設定為 INPUT_PULLUP 狀態
  // 這樣它就會在外部按鈕被按下時
  // 呈現 LOW 的狀態
  pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
}

void loop(){
  // 假如外部按鈕被按下
  if(digitalRead(2)==LOW){
    // 印出訊息
    Keyboard.print("Hello!");
  }
}

See also

Keyboard.end()
Keyboard.press()
Keyboard.print()
Keyboard.println()
Keyboard.release()
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.