Keyboard.print()

Last revision:2024/05/15

名称

Keyboard.print()

説明

接続しているPCに一つ以上のキーストロークを送信する。

Keyboard.print()を使う前に、Keyboard.begin()を呼ぶ必要がある。

書式

  • Keyboard.print(character)
  • Keyboard.print(characters)

C言語シグネチャ(avr)

size_t Keyboard_::print(const char[]);

size_t Keyboard_::print(char);

引数

characterキーストロークとしてPCに送信する文字もしくは整数。改行キーが付加される。
charactersキーストロークとしてPCに送信する文字列。改行キーが付加される。

戻り値

送信したバイト数。

コード例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#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!");
  }
}

注意

Keyboard.print()コマンドを使うと、Arduinoはキーボードを横取りする。このコマンドを使う前に制御可能であることを確認すること。キーボード制御状態をトグルする押しボタンを使うのが効果がある。

オリジナルのページ

https://docs.arduino.cc/language-reference/en/functions/usb/Keyboard/keyboardPrint/

実装の解析

まだ解析していません。

最終更新日

July 20, 2026

inserted by FC2 system