Hello there,
Just to clarify, I am not very experienced in coding, so bear with me.
In my project I'm building a new keyboard from scratch, new layout and everything. So I am using multiple simple pushbuttons to act as keys, and a Teensy 3.2 as "Keyboard" connected to my Mac (coding in Arduino app).
The buttons are not connected in rows and columns, but every button is individually connected to the Teensy, which might seem laborious, but it was easiest for me to do.
Every button gives out a character when pressed, except for 4 buttons (SPACE, BACKSPACE, NUM and COMBINATION). Every character-button is working, as well as space and backspace. (For this I used the instructions on the pjcr website https://www.pjrc.com/teensy/td_keyboard.html.)
What I want now is for the teensy to detect, if multiple buttons are pressed at the same time, therefore changing the output.
FOR EXAMPLE: If you press the "q"-button, a "q" is written. If you press the NUM-button + "q"-button, the output should change from "q" to "1".
So for the NUM-button, every character should be able to change to another printed output.
Then we have the COMBINATION-button (COMB), which should do a similar thing, but instead of just printing another output, it should be able to perform shortcuts.
FOR EXAMPLE: If you press the "a"-button, a "a" is written. If you press the COMB-button + "a"-button, the output should be similar to CMD+A (for Apple), so Select All.
The thing is, I know, that it is possible to use MODIFIER_KEYs, but with them you only press one button, and it will act as if two (or multiple) buttons were pressed simultaneously. But what I want, is that you actually have to press two buttons (just like on normal keyboards).
Here is my code so far:
I hope maybe someone gets what I mean and has an idea.
Thanks for your help, anyways!
Cheers,
Anna
Just to clarify, I am not very experienced in coding, so bear with me.
In my project I'm building a new keyboard from scratch, new layout and everything. So I am using multiple simple pushbuttons to act as keys, and a Teensy 3.2 as "Keyboard" connected to my Mac (coding in Arduino app).
The buttons are not connected in rows and columns, but every button is individually connected to the Teensy, which might seem laborious, but it was easiest for me to do.
Every button gives out a character when pressed, except for 4 buttons (SPACE, BACKSPACE, NUM and COMBINATION). Every character-button is working, as well as space and backspace. (For this I used the instructions on the pjcr website https://www.pjrc.com/teensy/td_keyboard.html.)
What I want now is for the teensy to detect, if multiple buttons are pressed at the same time, therefore changing the output.
FOR EXAMPLE: If you press the "q"-button, a "q" is written. If you press the NUM-button + "q"-button, the output should change from "q" to "1".
So for the NUM-button, every character should be able to change to another printed output.
Then we have the COMBINATION-button (COMB), which should do a similar thing, but instead of just printing another output, it should be able to perform shortcuts.
FOR EXAMPLE: If you press the "a"-button, a "a" is written. If you press the COMB-button + "a"-button, the output should be similar to CMD+A (for Apple), so Select All.
The thing is, I know, that it is possible to use MODIFIER_KEYs, but with them you only press one button, and it will act as if two (or multiple) buttons were pressed simultaneously. But what I want, is that you actually have to press two buttons (just like on normal keyboards).
Here is my code so far:
Code:
#include <Bounce.h>
#include <keyboard.h>
//Bounce NameOfKey = Bounce (PIN, Time);
Bounce BCKSP = Bounce (18, 10);
Bounce NUM = Bounce (14, 10);
Bounce q = Bounce (3, 10);
Bounce d = Bounce (1, 10);
Bounce a = Bounce (2, 10);
Bounce z = Bounce (0, 10);
Bounce r = Bounce (6, 10);
Bounce s = Bounce (4, 10);
Bounce x = Bounce (5, 10);
Bounce w = Bounce (9, 10);
Bounce h = Bounce (8, 10);
Bounce m = Bounce (7, 10);
Bounce b = Bounce (17, 10);
Bounce t = Bounce (15, 10);
Bounce c = Bounce (16, 10);
void setup() {
// put your setup code here, to run once:
// Set INPUT_PULLUP to have signal high when not pressed
//and low when connected to ground (pressed).
pinMode (18, INPUT_PULLUP);
pinMode (14, INPUT_PULLUP);
pinMode (3, INPUT_PULLUP);
pinMode (1, INPUT_PULLUP);
pinMode (2, INPUT_PULLUP);
pinMode (0, INPUT_PULLUP);
pinMode (6, INPUT_PULLUP);
pinMode (4, INPUT_PULLUP);
pinMode (5, INPUT_PULLUP);
pinMode (9, INPUT_PULLUP);
pinMode (8, INPUT_PULLUP);
pinMode (7, INPUT_PULLUP);
pinMode (17, INPUT_PULLUP);
pinMode (15, INPUT_PULLUP);
pinMode (16, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
BCKSP.update();
NUM.update();
q.update();
d.update();
a.update();
z.update();
r.update();
s.update();
x.update();
w.update();
h.update();
m.update();
b.update();
t.update();
c.update();
if (BCKSP.fallingEdge()) {
Keyboard.press(KEY_BACKSPACE);
Keyboard.release(KEY_BACKSPACE);
}
if (q.fallingEdge()) {
Keyboard.print("q");
}
if (d.fallingEdge()) {
Keyboard.print("d");
}
if (a.fallingEdge()) {
Keyboard.print("a");
}
if (z.fallingEdge()) {
Keyboard.print("z");
}
if (r.fallingEdge()) {
Keyboard.print("r");
}
if (s.fallingEdge()) {
Keyboard.print("s");
}
if (x.fallingEdge()) {
Keyboard.print("x");
}
if (w.fallingEdge()) {
Keyboard.print("w");
}
if (h.fallingEdge()) {
Keyboard.print("h");
}
if (m.fallingEdge()) {
Keyboard.print("m");
}
if (b.fallingEdge()) {
Keyboard.print("b");
}
if (t.fallingEdge()) {
Keyboard.print("t");
}
if (c.fallingEdge()) {
Keyboard.print("c");
}
}
I hope maybe someone gets what I mean and has an idea.
Thanks for your help, anyways!
Cheers,
Anna