說明
當與 Leonardo 或 Due 板一起使用時,Keyboard.begin()
開始模擬連接到計算機的鍵盤。要結束控製,請使用 Keyboard.end() 。
用法
Keyboard.begin()
Keyboard.begin(layout)
參數
layout
:要使用的鍵盤布局。此參數是可選的,默認為 KeyboardLayout_en_US
。
鍵盤布局
目前,該庫支持以下國家鍵盤布局:
-
KeyboardLayout_da_DK
:丹麥 -
KeyboardLayout_de_DE
:德國 -
KeyboardLayout_en_US
:美國 -
KeyboardLayout_es_ES
:西班牙 -
KeyboardLayout_fr_FR
:法國 -
KeyboardLayout_it_IT
:意大利 -
KeyboardLayout_sv_SE
:瑞典
返回
無
示例代碼
#include <Keyboard.h>
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);
Keyboard.begin();
}
void loop() {
//if the button is pressed
if (digitalRead(2) == LOW) {
//Send the message
Keyboard.print("Hello!");
}
}
注意事項和警告
可以通過複製和修改現有布局來創建自定義布局。請參閱鍵盤庫的 KeyboardLayout.h 文件中的說明。
相關用法
- Arduino Keyboard.println()用法及代碼示例
- Arduino Keyboard.releaseAll()用法及代碼示例
- Arduino Keyboard.press()用法及代碼示例
- Arduino Keyboard.write()用法及代碼示例
- Arduino Keyboard.release()用法及代碼示例
- Arduino Keyboard.print()用法及代碼示例
- Arduino Keyboard.end()用法及代碼示例
- Arduino long用法及代碼示例
- Arduino Arduino_EMBRYO_2 - setLengthXY()用法及代碼示例
- Arduino ~用法及代碼示例
- Arduino ArduinoBLE - bleDevice.advertisedServiceUuidCount()用法及代碼示例
- Arduino const用法及代碼示例
- Arduino Ethernet - server.begin()用法及代碼示例
- Arduino ArduinoBLE - BLEService()用法及代碼示例
- Arduino digitalWrite()用法及代碼示例
- Arduino ArduinoBLE - bleCharacteristic.subscribe()用法及代碼示例
- Arduino Servo - attach()用法及代碼示例
- Arduino write()用法及代碼示例
- Arduino Arduino_LSM9DS1 - readGyroscope()用法及代碼示例
- Arduino ArduinoSound - FFTAnalyzer.input()用法及代碼示例
- Arduino MKRGSM - gprs.attachGPRS()用法及代碼示例
- Arduino WiFiNINA - WiFi.config()用法及代碼示例
- Arduino MKRGSM - sms.read()用法及代碼示例
- Arduino MKRNB - getCurrentCarrier()用法及代碼示例
- Arduino Scheduler - Scheduler.startLoop()用法及代碼示例
注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 Keyboard.begin()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。