Keyboard.print()
描述
送出按键内容给已连接的电脑。
在呼叫 Keyboard.print()
函式之前,要先呼叫 Keyboard.begin() 函式。
注意:在您呼叫 Keyboard.print()
函式之后,86Duino 会接管您的键盘,模拟键盘按下按键的行为。建议在 86Duino 上透过外接开关,来切换电脑键盘和 86Duino 之间的控制权。
语法
Keyboard.print(character)
Keyboard.print(characters)
参数
character
: 一个要送给电脑的 char 或 int 型别的字元。
characters
: 送给电脑的字串(相当于连续敲击键盘按键)。
回传
送出的 byte 个数
范例
void setup() { // 将 pin 2 设定为 INPUT_PULLUP 状态 // 这样它就会在外部按钮被按下时 // 呈现 LOW 的状态 pinMode(2, INPUT_PULLUP); Keyboard.begin(); } void loop() { // 假如按键被按下 if(digitalRead(2)==LOW){ // 送出一段讯息 Keyboard.print("Hello!"); delay(100); } }
See also
- Keyboard.begin()
- Keyboard.end()
- Keyboard.press()
- 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.