Keyboard.println()

Last revision:2024/05/15

名称

Keyboard.println()

説明

接続しているPCに一つ以上のキーストロークと、その後、改行と復帰コードを送信する。

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

書式

  • Keyboard.println()
  • Keyboard.println(character)
  • Keyboard.println(characters)

C言語シグネチャ(avr)

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

size_t Keyboard_::println(char);

引数

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

戻り値

送信したバイト数。データ型: size_t

コード例

 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.println("Hello!");
  }
}

注意

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

オリジナルのページ

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

実装の解析

まだ解析していません。

最終更新日

August 16, 2026

inserted by FC2 system