I want to make a custom key board for a PC game using an Arduino Micro. Several of my buttons/keys will have to send multiple commands to the PC, an example of what I mean is "Left Ctrl" + "Left Shift" + "J".
I have watched a couple YouTube videos to under stand how to use a keypad matrix and the Keyboard.h Library. My question is one video spoke of setting the Rows as Inputs and Columns as Outputs pulled up and in code turn on one column then check if and what row was now high. My concern is time I am going to have an almost full keyboard.
The other video spoke of Keypad.h library, I'm confused on how to make the 2 libraries work together and send multiple commands like I mentioned earlier.
You have to master 3 parts:
- query a keyboard matrix, using the library
- generate key commands for the pressed key, using your own encoding table
- send the commands to the PC, via USB?
The last one is critical because it requires to turn the Micro USB from a Serial device into a HID device, if that's supported at all. Afterwards an ISP programmer is required to transfer new code to the controller.
… into a HID device, if that’s supported at all. Afterwards an ISP programmer is required to transfer new code to the controller.
It’s a Micro so keyboard is supported.
After reset the micro comes up as a serial device as usual,
if there is a faulty keystroke/mouse flooding sketch on it the micro can be held in reset until the IDE
starts uploading a new sketch. Maybe that will not work on the first try, but an ISP is not needed.
The Keypad library looks for key presses in a matrix of keys. Key switches are arranged in a matrix where each switch connects a unique pair of row and column. When the Keypad library detects a switch being closed it returns the single character (non-zero) that represents that intersection in the matrix. You just need to assign a unique one-character name to each of your key switches.
The Keyboard library sends key presses and releases to the USB host. It can send any combination of the eight shift keys (Left shift, Left Ctrl, Left Alt...) and up to 6 other keys. You'll probably only use 1 other key. When you get a key pressed, use the Keyboard.press() function for each shift key, then for the non-shift key, then Keyboard.releaseAll() to release the keys so they don't repeat.