當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Arduino USBHost - getModifiers()用法及代碼示例

說明

報告在連接的 USB 鍵盤上按下或釋放的任何修飾鍵。

用法

keyboard.getModifiers()

參數

返回

int:被按下的修飾鍵的數字表示。鍵的值如下。

  • LeftCtrl = 1
  • LeftShift = 2
  • Alt = 4
  • LeftCmd = 8
  • RightCtrl = 16
  • RightShift = 32
  • AltGr = 64
  • RightCmd = 128

示例

#include <KeyboardController.h>

// Initialize USB Controller
USBHost usb;

// Attach Keyboard controller to USB
KeyboardController keyboard(usb);

void setup(){
  Serial.begin(9600);
}

void loop(){
  usb.Task();
  int mod = keyboard.getModifiers();
  Serial.print("mod: ");
  Serial.print(mod);
}

相關用法


注:本文由純淨天空篩選整理自arduino.cc大神的英文原創作品 USBHost - getModifiers()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。