Keyboard.press()
설명
Keyboard.press() 가 호출되면 키보드에서 키를 누른 상태로 유지되는 것처럼 작동합니다. modifier keys를 사용할 때 유용합니다. 키눌림을 끝내려면 Keyboard.release() 또는 Keyboard.releaseAll()를 사용하십시오.
press()를 사용하기전에 Keyboard.begin()를 호출해야합니다.
문법
Keyboard.press()
매개변수
- 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.releaseAll();
// wait for new window to open:
delay(1000);
}
더보기
- 언어 : Arduino - Keyboard
- 언어 : Keyboard.begin()
- 언어 : Keyboard.end()
- 언어 : Keyboard Modifiers
- 언어 : Keyboard.print()
- 언어 : Keyboard.println()
- 언어 : Keyboard.release()
- 언어 : Keyboard.write()
※ ARDUINO BUY RECOMMENDATION
Arduino UNO R3 | |
Arduino Starter Kit |
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.