Skip to content

Instantly share code, notes, and snippets.

@tokyoff
Last active September 12, 2019 14:30
Show Gist options
  • Save tokyoff/0eb47ff4d597d051014d47c2eeddf254 to your computer and use it in GitHub Desktop.
Save tokyoff/0eb47ff4d597d051014d47c2eeddf254 to your computer and use it in GitHub Desktop.
画面をサッと隠せるワンボタンキーボード用ソースコード(Win用)
//------------------------------------
// 画面をサッと隠せるキーボード Win用
// (Ctl + Alt + Del)
// https://www.one-button-key.com/
//------------------------------------
#include "Keyboard.h"
#define PIN_KEYSW (9)
int prevKeyState;
int currKeyState;
void setup() {
pinMode(PIN_KEYSW, INPUT_PULLUP);
prevKeyState = HIGH;
currKeyState = HIGH;
Keyboard.begin();
}
void loop() {
currKeyState = digitalRead(PIN_KEYSW);
// キースイッチが押された
if ((prevKeyState == HIGH) && (currKeyState == LOW)) {
Keyboard.press(KEY_LEFT_CTRL); // Control
Keyboard.press(KEY_LEFT_ALT); // Alt
Keyboard.press(KEY_DELETE); // Delete
delay(10); // 10ms待つ
Keyboard.releaseAll(); // すべて放す
}
prevKeyState = currKeyState;
delay(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment