Keyboard.press doesn't like it when I feed it a string

usererror

Active member
Code:
String currentkey;
void setup() {
delay(3000); // just to make sure I don't get stuck in a loop
currentkey = MODIFIERKEY_CTRL;
}
void loop() {
Keyboard.press(currentkey);
}
A trimmed down example.

The aim was to have a matrix to lookup my "layer" (like in QMK) and then eventually down the line, feed that into Keyboard.press/release.

I've tried it so many ways I'm a bit turned around at this point.
The always varying error points to:
/usr/share/arduino/hardware/teensy/avr/cores/teensy4/usb_keyboard.h:101:7

If I can point directly at the keycode, that'd work fine for me.. As long as I can pull it out of a matrix and test it a bit to check if its a modifier or other special key, etc, before passing it on to the keyboard library.

I just want to avoid a few hundred if statements to test every key and have its own line for the Keyboard.press and release.


Way out of practice, and forgotten a lot of the basics of C/C++, so I think I'm just confusing myself.


EDIT: I'm using the 4.1, in case that makes a difference down the line of inquiry.
 
The code in {local}\hardware\teensy\avr\cores\teensy4\usb_keyboard.h

Shows: void press(uint16_t n) { usb_keyboard_press_keycode(n); }

That does not allow for a String variable, but expects a uint16_t.

Seems the allowable 16 bit values values might be those in: {local}\hardware\teensy\avr\cores\teensy4\keylayouts.h
 
Thank you defragster. I should have noticed that. Changed the type for both that variable and the matrix I am using to uint16_t and aside from a few warnings unrelated to this, it compiled.
 
Glad it helped. Was the String passing giving a warning - or did it get converted silently ... to not work?
 
@ defragster
The warnings were related to this line
Code:
warning: multi-character character constant [-Wmultichar]
   if (currentkey == 'MO' || 'OSL' || 'TG' || 'TT') {
I tried with ' and ".
I wrote it with the matrix being a string, but converting it to unit16_t seems to have caused an issue there.

I have not read through the chain and tested things along the path yet. It is something I need to square away, but it is also something I'm happy to spend some time writing tests to see precisely what is happening. Slowly regaining some of the ground I lost spending a long time on non-code projects.

The call to get currentkey is to the layerMatrix
Code:
  currentkey = layerMatrix[currentLayerNumber][switchNumber0];

The matrix looks like this (its just 12 copies of itself at the moment for testing purposes):
Code:
uint16_t layerMatrix[12][73] = {
{MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
 
Not sure if Keyboard.print will cause problems with persistence (when a key is held), but if it just keeps sending it, it should be the same end result if I'm thinking about it correct, right?
 
Unfortunately it looks like after refreshing my memory, Keyboard.print won't work, as this is a full keyboard. It needs all the keys.

I'm 100% not understanding whats happening in usb_keyboard.c

But, it is converting (example at end)
Key_A to a uint16_t variable here, correct? I've never seen #define used this way and trying to find examples I could parse didn't play out for me (yet, I'll keep at it).
Is there not a way to pipe a variable into Keyboard.press(); / release that'd emulate Keyboard.press(Key_A); ?
If I have to, I guess I can write a lot of if statements and functions to split everything out and say "if you find Key_A, then run the Keyboard.press(Key_A); It just seems to me like I have to be doing something wrong.

The only reason it is a string is I need to be able to store each key in a matrix so I can look up what that key is at that moment, because its not a constant. That'd be maybe 1000 lines of code to do what I'd think could be done in 5. I'm 100% not understanding something about how the library works (I get that USB stuff is a pain to implement, so if it is what it is, I get that, I just want to understand it a bit better and maybe find a way to work with it. If there is a way to tweak the library that'd work for me too. I can convert my values in the matrix to other values no problem if needed. They don't have to be human readable (it helps but isn't mission critical at all).





Code:
#define KEY_MEDIA_PLAY_SKIP     ( 0xCE | 0xE400 )
#define KEY_MEDIA_MUTE          ( 0xE2 | 0xE400 )
#define KEY_MEDIA_VOLUME_INC    ( 0xE9 | 0xE400 )
#define KEY_MEDIA_VOLUME_DEC    ( 0xEA | 0xE400 )

#define KEY_A                   (   4  | 0xF000 )
#define KEY_B                   (   5  | 0xF000 )
#define KEY_C                   (   6  | 0xF000 )
 
I'm afraid I don't really understand your question. I don't know what you mean by phrases like "pipe a variable into Keyboard.press(); / release that'd emulate Keyboard.press(Key_A); ?" Maybe this would make more sense in the context of understanding whatever sort of project you're building, but there too, I just don't understand words like "The aim was to have a matrix to lookup my "layer" (like in QMK) and then eventually down the line, feed that into Keyboard.press/release."

But maybe I can help with this question.

I'm 100% not understanding something about how the library works ...

First, if you haven't seen the official documentation, here's the link.

https://www.pjrc.com/teensy/td_keyboard.html

The basic idea is Teensy's Keyboard class tries to give you 3 ways to transmit data.

1: High level print(string) function
2: Medium level press(keycode) and release(keycode) functions
3: Low level set_keyN() and send_now() functions

The low level API gives you direct access to the HID report bytes, the 6 key values and bitmask of modifier keys. You can only use the direct low-level key codes and you have to do all the work of assigning to the 6 possible slots if you wish to have more than 1 key pressed at a time. Like most very low level access, this involves a lot of tedious and error-prone work.

International keyboard layout is one of the many details the low level way assumes you will handle. If you're not familiar with this, the main thing to understand is all USB keyboards are created equal (as cheaply as possible). A keyboard sold in the United States with keys QWERTY is exactly the same electronics as a keyboard sold in France with keys AZERTY. They just put different plastic caps on identical electronics. So the low-level KEY_Q is the physical key located to the right of the tab key, which is transmitted when a human presses the "Q" key on an English keyboard or "A" key on a French keyboard. Even though the defines use the US English convention, they are actually just the physical locations without any international keycap layout factored in.

The medium level press() and release() functions try to give you a sort of Swiss Arm Knife style convenience. You can use the low level USB key codes. Or you can give it ASCII and Unicode (up to U+C1FF) which get translated to key codes depending on the keyboard layout (from the Tools > Keyboard Layout menu). The layout translation layer "knows" about non-ASCII keys used in some countries, like the French keyboard having modifiers for the number keys '2' and '7' to type the letter 'e' with grave or acute accents: 'é' or 'è'. Obviously Keyboard.press() has to take more than 8 bits to support Unicode code points as inputs. The raw USB key codes are defined with upper 8 bits so they don't conflict with ASCII or the supported Unicode range, or the packed UTF8 format that gcc uses if UTF8 is used inside a char constant, such as with Keyboard.press('é'). Remember, Keyboard.press() is trying to be a Swiss Arm Knife offering a lot of different tools built into a unified API. This comment from the code explains it best.

Code:
// Input can be:
//     32 - 127     ASCII direct (U+0020 to U+007F) <-- uses layout
//    128 - 0xC1FF  Unicode direct (U+0080 to U+C1FF) <-- uses layout
// 0xC200 - 0xDFFF  Unicode UTF8 packed (U+0080 to U+07FF) <-- uses layout
// 0xE000 - 0xE0FF  Modifier key (bitmap, 8 keys, shift/ctrl/alt/gui)
// 0xE200 - 0xE2FF  System key (HID usage code, within usage page 1)
// 0xE400 - 0xE7FF  Media/Consumer key (HID usage code, within usage page 12)
// 0xF000 - 0xFFFF  Normal key (HID usage code, within usage page 7)

The reason Keyboard.press() takes 16 bit input is it's trying to allow you to give it any of these 7 types of input. Things are defined in this way to allow as much Unicode range as possible and also automatically work with UTF8 packed char constants. It's meant to "just work" in all the common ways people tend to use it. The defines in keylayouts.h give 16 bit numbers where the lower 8 bits are the actual USB HID usage numbers and the upper 8 bits are provided only for the purpose of allowing Keyboard.press() to automatically (and hopefully conveniently) figure out which type of input you meant.

The high level API using Keyboard.print(string) doesn't give access to the keycodes or special keys. It is meant to type strings. It adds UTF8 decoding. The Arduino IDE automatically saves your code as UTF8. So when you call Keyboard.print(string), the string is decoded from 8 bit UTF8 into 16 bit Unicode code points and then Keyboard.press() and Keyboard.release() are called for each Unicode character of your string. Keyboard.print() is meant for people who just want to create projects that type known text to a PC and don't want to have to deal with any low-level details.

Whether this really answered your questions about "pipe a variable into Keyboard.press()" or having a matrix lookup layer, I really don't know. But hopefully it helps explain the rationale behind the Keyboard class design. Maybe that can help?
 
Last edited:
So, I think I have it sorted, but I'll know more when I modify my existing code.

The project is a scratch made keyboard. I am using hall sensors and modified optical switches (I had them, but it became too expensive to implement, and they contain neither the IR LED nor IR receiver internally so they are basically just plastic that can move a magnet).

In october, I got myself a used 3D printer and have gotten it dialed in and modified to hit the necessary 50 micron tolerances I need. So, I adapted my optical design I was unable to get parts to implement to a hall sensor based design, with the hall sensors located in the mid-plate (this is why tolerances are so important, any deviation there changes how the switch performs). The hall sensors can be captive in cavities using through-hole parts, rather than requiring a PCB like the optical parts would, allowing me to use far less expensive (and actually available) components, and gives me any hope of being able to handle the costs associated with some trial/error leading to revisions.

Why bother: I have some issues with my hands. They don't work right anymore, and are likely to get much worse. It is preventing me from taking on a lot of what I'd like to do. One of the issues that occurs is it often leads to pressing keys off center, which kills mechanical switches quite quickly, regardless of the quality. Hence optical or hall. If I stuck with standard mechanical switches I wouldn't have spent a month designing extremely complex 3D models (which I have no complaints about).

Most of the split keyboards are not full keyboards, I've yet to find an ortholinear board that would do, and I require *all the buttons*. And to just shortcut through a long list of circumstances, I couldn't buy what I needed, and nobody makes what I want.

I technically could probably do what I need as a bare minimum using QMK, but there are issues there still too.

The aim with the teensy side is a bit of a mess. Its two teensies, an ESP32, undecided but one or two oleds, an analog stick (I figure if I'm going through all this trouble I might as well give it a try and see if it helps in any way), and a few other oddball things like full RGB explicitly because it indicates state, but also gives me an excuse to spend some time writing animations for it.

Just to walk past any confusion that is likely to occur, every switch is directly wired to a pin. That is a part of why I'm using a pair of 4.1s.

I intend to use the host ports for passthrough, piping one keyboard into the other, but if I don't get there on the first go, I'm fine with that. I can give each a usb port on the host or use serial if needed. Enabling passthrough though would allow a mouse to be plugged right into the keyboard making it a single wire to the host device (PC, Phone, etc) which I think would be a cool if unnecessary feature.
At this time I'm just aiming to get a bare minimum working.

One of the primary features of QMK is something they call "layers", where you have multiple key layouts that you can switch between. So you could have a tiny keyboard with A-Z, and push a modifier key to get access to other symbols and other modifiers. I intend to do this for things like media keys and shortcuts for various programs, because hitting multiple keys at the same time with regularity has become a problematic endeviour for me.

So, the idea is there is an array that maps the pins of the teensy to the numbers of the switches.

For one half of the keyboard it may look like this: Each (I don't know correct terminology here) "slot" corrisponds to the switch number, as far as the keyboard sees it. The number inside each slot is the pin of that switch. I skipped over a few pins here, because I was intending to use them for other things, like SPI and i2c to talk to other devices.

This is in an array so it can be more easily modified later. The code may be re-used with a different hardware configuration, so hard-coding it to specific pins would make that much more challenging. This is my first build of this keyboard design, so I'd rather not make it harder on myself if I need to completely change something up down the road.

int switchPins[36] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41};

Then, it uses the switch number it gets from there, along with what layer the keyboard is set to use in that moment. It may find it is on layer 2, because a button has been pressed at some point in the past to change it from the default layer 0, and so now, what would be button A in layer 0 is actually a button to change the layer again to something different. If so, it does that. Otherwise if its an F1 key or otherwise, it'll send that information to the host (PC or, if using usb passthrough, to the other teensy which will send it down the line).

Because the layers need to be configurable so I can change them as I discover what suits my needs, and as my needs change, I was going to use QMK's configurator and then convert their naming scheme to something suitable for the teensy. That is where the solution seems to be.

If I store the numerical value of each key in a matrix, with a row representing a single layer, I can look it up in one shot:

uint16_t layerMatrixNumerical [2] [7] {
{ 97, 98, 99, 100, 101, 102, 103 },
{ 97, 98, 99, 100, 101, 102, 103 }
};

currentkeymatrix = layerMatrixNumerical [currentlayer][thisswitch];
Keyboard.press(currentkeymatrix);


Using 97 (a) where KEY_A was, everything seems to be working for me, so far. I still have not folded this into the main code and only used it in a test sketch.

Converting the QMK key names from their generator into the numerical names the teensy wants can just be done with a bash script, or manually even.
I'll figure that out later. My goal was to eventually connect the RGB to openRGB via rawHID, as well as be able to push changes to the layers through a rawHID application, but I'm not taking that on until much later in the project. It'll be my excuse to start getting back into Rust.

I'm enjoying the project but I took about a year off from writing code to take on other things, and for me, it is a highly perishable skill. I'm slowly relearning things, but I am finding I'm missing things I really should have caught the first time around. The patience you've shown with me is very much appreciated.
 
BriComp, that is a great suggestion.

I have IO expanders, and a few other method to get there, but it winds up being bulkier and can cause timing conflicts between devices (that I'm sure can be worked around but I'm not so sure I understand enough about the communications protocols to accomplish that) as well as add a fair bit of cost (also, consider the shipping costs add up as well when ordering from multiple vendors).
I know the 4.1 is pricey (a great value for what you get, so much so that if I could budget it I'd order a handful of spares for my other dozen HID projects, but expensive compared to a lot of options more commonly used for keyboards), but about a year ago when I was gong the optical route, I determined that it'd be the simpler, cheaper, more compact route. I already have two of them because of that, and I really thought through the process then so I'm trying to recycle as many of my past decisions as I can, because I don't remember all of the reasons for them, so I'm leaning toward just trusting my past-self.

Originally because I was going optical, I thought, why not also work toward the lowest latency I can as well. I'm still aiming for that, though I gave up quite a bit of ground going with an older switching hall sensor (availability and price were driving factors). USB 2.0 enabling 8khz polling rates certainly is enticing.
Due to a disconnect between action and sensation in my hands, reducing latency helps me get better feedback as well.

With the 4.1, with each switch wired in directly, I could also make use of interrupts on both rising and falling edges to trigger the press, release of each switch.
I don't know if I want to do that or if there is a trap there that I'm not thinking of, but I do like the option.

Takeaway: I'm doing it the way I'm doing it for a few good reasons, a few bad reasons, and a lot of reasons I don't remember.
 
Some things I thought I said that I didn't make clear:
Optical means no-go on a grid.. just won't work. I'm sure there is a way to do it, but its starts getting extremely costly due to the quantity and variety of components required.
I'm not going optical anymore, but I already have the 4.1s because I purchased them for that project before the rest of the parts I was going to use stopped being attainable.

I may do IO expanders anyway, but if I do, it'll be to add back in the switches I already cut from it because there were too few pins, and they will be polled at a slower rate than the rest of the switches due to limitations of the IO expanders I could get. There are multiplexers and other options if I remember right that I looked at, and I don't recall why I didn't go with them.

Ultimately, discounting shipping, the amount of expander chips I'd have to add would wind up eating up the cost difference between a 4.0 and a 4.1 on just the first expander, and then just raising the cost from there (and you have to double it).

I was also intending to add in a uSD card to store bitmaps and some other things I may want to add on as a project. 7936K is a lot of flash memory, but I have a way of using up whatever I've got plus some any time I add an OLED to something. I tried to run just my basic proof of concept OLED animations on a Teensy LC and it had half the space I'd need. That was just *one of many* animations. So, then giving up more pins to uSD, and added cost to add an adapter.

Just in case anyone is considering a similar project who find this thread.
 
Wow, that's an impressive & ambitious list of features!

Sounds like you got it working with Keyboard.press()

Using 97 (a) where KEY_A was, everything seems to be working for me, so far. I still have not folded this into the main code and only used it in a test sketch.

Sounds like a lot of the open questions are about ways to do the programming which translates raw sensor events to the data you'll pass into Keyboard.press(). The good news is we have a long history of pretty good success helping with those sorts of questions on this forum. But it is indeed easy to get lost with imprecise or unusual terminology. Almost always better to put effort into composing a small but complete program which demonstrates the problem, so anyone can just copy it into Arduino and run it on their Teensy to experience the issue. Often the subtle details like how a variable is defined make all the difference, so showing a complete program rather than only small code fragments is the best way to get help.
 
I figure I might as well give an update as to the status and invite any critique of my methods if anyone feels like it.

It can currently accept a QMK layer configuration generated using https://config.qmk.fm/
It checks that against a translation array, and finds the position in that array, then grabs the decimal keycode from a second translation array.
It then checks if that is within the *standard* range for decimal keycodes which are known to the keyboard library. If so, it passes that on to the library as is.
If not, it handles them manually with a whole lot of switch cases.

I have not implemented every switch(button) possible yet. Only 244 in the translation arrays, and fewer implemented in the switch(switch case). More will come. For now this is plenty.

I'm using hall sensors with a 10k pullup (A3144 if I remember right, an old discontinued model, switching, non latching).
I have some analog ones as well as some latching, so I may experiment with that later (I already have tried them out, but until I use them in practice I won't know if its worth the extra hassle).
Using SK9822 addressable LEDs, which I have not implemented yet in this code. That can wait.
I may run into issues with a lack of capacitors in place. Not sure if I need them, or how close to the switches and LEDs they need to be, or what value I need. I have some recommendations written down, but I've only got one switch installed in a test-plate (not representative of the final product) so I think I can put off making the call on that just yet.

I had a weird bug I'd accidentally made for myself so there are a few things switched off and moved around that probably shouldn't be. But, it runs. At the moment, on a 3.2 (I was testing on an LC and ran out of ram. I don't have a 4.1 with pins atm).

IMG_20230115_043817353_01_sm.jpg

IMG_20230115_043831696_sm.jpg

A *maybe* still accurate quick flowchart I intend to clean up and have for future reference.
flowchart-for-absolutef-kb.12jan2023.drawio.jpg

Code:
#define testing
//#define testingLED


#define USB_LED_CAPS_LOCK 1

#define keyboardSide Left //  -- You must define this for each side of the keyboard you flash.
//#define keyboardSide Right

//int currentLayerNumber = 0; // current layer number
int currentLayerNumber = 0; // current layer number


uint16_t currentkey; // stores the current key in use - was String, may need to be String
char *currentkeyChar;
int updateSwitch; // total hack to try to bypass the generated updateswitch variable

int switchPins[36] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41};

int joystickPins[] = {22, 23};
int analogPins[] = {};

int oledPins[] = {24, 25};

int rgbPins[] = {26, 27};

int switchNumber;

const int BuiltInLED = 13; // pin used for built-in LED on Teensy


int switchLookup;  // used globally by each updateSwitch[x]() function to reduce performance but ease writing by making copypasta easier

char *layerMatrix[1][73] = {
 
  {"KC_ESC", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "KC_F9", "KC_F10", "KC_F11", "KC_F12", "KC_PSCR", "KC_GRV", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_6", "KC_7", "KC_8", "KC_9", "KC_0", "KC_MINS", "KC_EQL", "KC_BSLS", "KC_BSPC", "KC_HOME", "KC_Q", "KC_W", "KC_E", "KC_R", "KC_T", "KC_Y", "KC_U", "KC_I", "KC_O", "KC_P", "KC_LBRC", "KC_RBRC", "KC_BSLS", "KC_DEL", "KC_END", "KC_A", "KC_S", "KC_D", "KC_F", "KC_G", "KC_H", "KC_J", "KC_K", "KC_L", "KC_SCLN", "KC_QUOT", "KC_ENT", "KC_LSFT", "KC_Z", "KC_X", "KC_C", "KC_V", "KC_B", "KC_N", "KC_M", "KC_COMM", "KC_DOT", "KC_SLSH", "KC_RSFT", "KC_LCTL", "KC_LGUI", "KC_LALT", "KC_SPC",}
  };
/*
char *layerMatrix[12][73] = {
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", "KC_A", KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", "KC_T", KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {"KC_ESC", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "KC_F9", "KC_F10", "KC_F11", "KC_F12", "KC_PSCR", "KC_GRV", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_6", "KC_7", "KC_8", "KC_9", "KC_0", "KC_MINS", "KC_EQL", "KC_BSLS", "KC_BSPC", "KC_HOME", "KC_Q", "KC_W", "KC_E", "KC_R", "KC_T", "KC_Y", "KC_U", "KC_I", "KC_O", "KC_P", "KC_LBRC", "KC_RBRC", "KC_BSLS", "KC_DEL", "KC_END", "KC_A", "KC_S", "KC_D", "KC_F", "KC_G", "KC_H", "KC_J", "KC_K", "KC_L", "KC_SCLN", "KC_QUOT", "KC_ENT", "KC_LSFT", "KC_Z", "KC_X", "KC_C", "KC_V", "KC_B", "KC_N", "KC_M", "KC_COMM", "KC_DOT", "KC_SLSH", "KC_RSFT", "KC_LCTL", "KC_LGUI", "KC_LALT", "KC_SPC",},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN},
  {MODIFIERKEY_LEFT_CTRL, MODIFIERKEY_LEFT_SHIFT, MODIFIERKEY_LEFT_ALT, MODIFIERKEY_LEFT_GUI, KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_0, KEY_ENTER, KEY_ESC, KEY_BACKSPACE, KEY_TAB, KEY_SPACE, KEY_MINUS, KEY_EQUAL, KEY_LEFT_BRACE, KEY_RIGHT_BRACE, KEY_BACKSLASH, KEY_SEMICOLON, KEY_QUOTE, KEY_TILDE, KEY_COMMA, KEY_PERIOD, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_PRINTSCREEN, KEY_HOME, KEY_PAGE_UP, KEY_DELETE, KEY_END, KEY_PAGE_DOWN}
};
*/


int matrixSize1 = 244; // this needs to match the matrix size for *translationArrayQMK, and both *translationArrayQMK and translationArrayDecimal need to be the same size.
char *translationArrayQMK[244] = {"KC_NO", "KC_TRNS", "KC_SPC", "KC_EXLM", "KC_DQT", "KC_HASH", "KC_DLR", "KC_PERC", "KC_AMPR", "KC_DQUO", "KC_LPRN", "KC_RPRN", "KC_ASTR", "KC_PLUS", "KC_COMM", "KC_MINS", "KC_DOT", "KC_SLSH", "KC_0", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_6", "KC_7", "KC_8", "KC_9", "KC_COLN", "KC_SCLN", "KC_LT", "KC_EQL", "KC_GT", "KC_QUES", "KC_AT", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "KC_LBRC", "KC_BSLS", "KC_RBRC", "KC_CIRC", "KC_UNDS", "KC_GRV", "KC_A", "KC_B", "KC_C", "KC_D", "KC_E", "KC_F", "KC_G", "KC_H", "KC_I", "KC_J", "KC_K", "KC_L", "KC_M", "KC_N", "KC_O", "KC_P", "KC_Q", "KC_R", "KC_S", "KC_T", "KC_U", "KC_V", "KC_W", "KC_X", "KC_Y", "KC_Z", "KC_LCBR", "KC_PIPE", "KC_RCBR", "KC_TILD", "KC_BSPC", "RGB_VAI", "RGB_VAD", "RGB_MOD", "RGB_TOG", "JS_0", "JS_1", "JS_2", "JS_3", "JS_4", "JS_5", "JS_6", "JS_7", "JS_8", "JS_9", "JS_10", "JS_11", "JS_12", "JS_13", "JS_14", "JS_15", "JS_16", "JS_17", "JS_18", "JS_19", "JS_20", "JS_21", "JS_22", "JS_23", "JS_24", "JS_25", "JS_26", "JS_27", "JS_28", "JS_29", "JS_30", "JS_31", "OU_USB", "OU_BT", "KC_MFFD", "KC_MRWD", "", "", "", "", "", "", "", "", "", "KC_KB_POWER", "KC_PWR", "KC_SLEP", "KC_WAKE", "KC_KB_MUTE", "KC_MUTE", "KC_KB_VOLUME_UP", "KC_VOLU", "KC_KB_VOLUME_DOWN", "KC_VOLD", "KC_MNXT", "KC_MPRV", "KC_MSTP", "KC_MPLY", "KC_EJCT", "KC_CUT", "KC_COPY", "KC_PASTE", "KC_F13", "KC_F14", "KC_F15", "KC_F16", "KC_F17", "KC_F18", "KC_F19", "KC_F20", "KC_F21", "KC_F22", "KC_F23", "KC_F24", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "KC_F9", "KC_F10", "KC_F11", "KC_F12", "KC_PSCR", "KC_SCRL", "KC_PAUS", "KC_INS", "KC_HOME", "KC_PGUP", "KC_DEL", "KC_END", "KC_PGDN", "KC_RGHT", "KC_LEFT", "KC_DOWN", "KC_UP", "KC_NUM", "KC_PSLS", "KC_PAST", "KC_PMNS", "KC_PPLS", "KC_PENT", "KC_P1", "KC_P2", "KC_P3", "KC_P4", "KC_P5", "KC_P6", "KC_P7", "KC_P8", "KC_P9", "KC_P0", "KC_PDOT", "KC_NUBS", "KC_APP", "KC_CAPS", "KC_QUOT", "KC_NUHS", "KC_TAB", "KC_ENT", "KC_ESC", "KC_LCTL", "KC_LSFT", "KC_LALT", "KC_LGUI", "KC_RCTL", "KC_RSFT", "KC_RALT", "KC_RGUI", "DF", "MO", "OSL", "LM", "LT", "TG", "TO", "TT", "OU_AUTO"};
// this one was just a test, replacing "", with "NA", to see if that'd fix it being confused and firing off 65 instead of 97 (A vs a)
//char *translationArrayQMK[244] = {"KC_NO", "KC_TRNS", "KC_SPC", "KC_EXLM", "KC_DQT", "KC_HASH", "KC_DLR", "KC_PERC", "KC_AMPR", "KC_DQUO", "KC_LPRN", "KC_RPRN", "KC_ASTR", "KC_PLUS", "KC_COMM", "KC_MINS", "KC_DOT", "KC_SLSH", "KC_0", "KC_1", "KC_2", "KC_3", "KC_4", "KC_5", "KC_6", "KC_7", "KC_8", "KC_9", "KC_COLN", "KC_SCLN", "KC_LT", "KC_EQL", "KC_GT", "KC_QUES", "KC_AT", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "KC_LBRC", "KC_BSLS", "KC_RBRC", "KC_CIRC", "KC_UNDS", "KC_GRV", "KC_A", "KC_B", "KC_C", "KC_D", "KC_E", "KC_F", "KC_G", "KC_H", "KC_I", "KC_J", "KC_K", "KC_L", "KC_M", "KC_N", "KC_O", "KC_P", "KC_Q", "KC_R", "KC_S", "KC_T", "KC_U", "KC_V", "KC_W", "KC_X", "KC_Y", "KC_Z", "KC_LCBR", "KC_PIPE", "KC_RCBR", "KC_TILD", "KC_BSPC", "RGB_VAI", "RGB_VAD", "RGB_MOD", "RGB_TOG", "JS_0", "JS_1", "JS_2", "JS_3", "JS_4", "JS_5", "JS_6", "JS_7", "JS_8", "JS_9", "JS_10", "JS_11", "JS_12", "JS_13", "JS_14", "JS_15", "JS_16", "JS_17", "JS_18", "JS_19", "JS_20", "JS_21", "JS_22", "JS_23", "JS_24", "JS_25", "JS_26", "JS_27", "JS_28", "JS_29", "JS_30", "JS_31", "OU_USB", "OU_BT", "KC_MFFD", "KC_MRWD", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "NA", "KC_KB_POWER", "KC_PWR", "KC_SLEP", "KC_WAKE", "KC_KB_MUTE", "KC_MUTE", "KC_KB_VOLUME_UP", "KC_VOLU", "KC_KB_VOLUME_DOWN", "KC_VOLD", "KC_MNXT", "KC_MPRV", "KC_MSTP", "KC_MPLY", "KC_EJCT", "KC_CUT", "KC_COPY", "KC_PASTE", "KC_F13", "KC_F14", "KC_F15", "KC_F16", "KC_F17", "KC_F18", "KC_F19", "KC_F20", "KC_F21", "KC_F22", "KC_F23", "KC_F24", "KC_F1", "KC_F2", "KC_F3", "KC_F4", "KC_F5", "KC_F6", "KC_F7", "KC_F8", "KC_F9", "KC_F10", "KC_F11", "KC_F12", "KC_PSCR", "KC_SCRL", "KC_PAUS", "KC_INS", "KC_HOME", "KC_PGUP", "KC_DEL", "KC_END", "KC_PGDN", "KC_RGHT", "KC_LEFT", "KC_DOWN", "KC_UP", "KC_NUM", "KC_PSLS", "KC_PAST", "KC_PMNS", "KC_PPLS", "KC_PENT", "KC_P1", "KC_P2", "KC_P3", "KC_P4", "KC_P5", "KC_P6", "KC_P7", "KC_P8", "KC_P9", "KC_P0", "KC_PDOT", "KC_NUBS", "KC_APP", "KC_CAPS", "KC_QUOT", "KC_NUHS", "KC_TAB", "KC_ENT", "KC_ESC", "KC_LCTL", "KC_LSFT", "KC_LALT", "KC_LGUI", "KC_RCTL", "KC_RSFT", "KC_RALT", "KC_RGUI", "DF", "MO", "OSL", "LM", "LT", "TG", "TO", "TT", "OU_AUTO"};
uint16_t translationArrayDecimal[244] = {0, 1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 305, 306, 307, 308, 308, 309, 309, 310, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397};
int wantedpos;

void setup()
{
  pinMode(BuiltInLED, OUTPUT);
#if defined testing
  Serial.begin(115200);
  Serial.println("Serial Begin :: TESTING OUTPUT ACTIVE");
#endif
#if defined testingLED
  pinMode(BuiltInLED, OUTPUT);
#endif

  // Attach all pins to interrupt, set to INPUT_PULLUP
  pinMode(15, INPUT_PULLUP); // used for LC testing (otherwise it can be any pin)


  attachInterrupt(digitalPinToInterrupt(switchPins[0]), updateSwitch0    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[1]), updateSwitch1    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[2]), updateSwitch2    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[3]), updateSwitch3    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[4]), updateSwitch4    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[5]), updateSwitch5    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[6]), updateSwitch6    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[7]), updateSwitch7    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[8]), updateSwitch8    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[9]), updateSwitch9    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[10]), updateSwitch10    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[11]), updateSwitch11    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[12]), updateSwitch12    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[13]), updateSwitch13    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[14]), updateSwitch14    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[15]), updateSwitch15    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[16]), updateSwitch16    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[17]), updateSwitch17    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[18]), updateSwitch18    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[19]), updateSwitch19    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[20]), updateSwitch20    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[21]), updateSwitch21    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[22]), updateSwitch22    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[23]), updateSwitch23    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[24]), updateSwitch24    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[25]), updateSwitch25    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[26]), updateSwitch26    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[27]), updateSwitch27    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[28]), updateSwitch28    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[29]), updateSwitch29    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[30]), updateSwitch30    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[31]), updateSwitch31    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[32]), updateSwitch32    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[33]), updateSwitch33    , CHANGE);
  attachInterrupt(digitalPinToInterrupt(switchPins[34]), updateSwitch34    , CHANGE);


}

void loop()
{ ////////////////////////// CAPSLOCK LED CODE - BEGIN ////////////////////////////////
  if (keyboard_leds & (1 << USB_LED_CAPS_LOCK)) // checks that the caps lock bit is set
  {
    // CapsLock is ON
    #if defined testingLED
    digitalWrite(BuiltInLED, HIGH); // Later, this should lookup what key capslock is set to and lookup what color it should change the RGB LED to
    #endif
  }
  else
  {
    // CapsLock is OFF
    #if defined testingLED
    digitalWrite(BuiltInLED, LOW); // Later, this should lookup what key capslock is set to and lookup what color it should change the RGB LED to
    #endif
  }
  ////////////////////////// CAPSLOCK LED CODE - END ////////////////////////////////
}

void updateSwitch0() {
  switchLookup = 0;
  sendSwitch();
}
void updateSwitch1() {
  switchLookup = 1;
  sendSwitch();
}
void updateSwitch2() {
  switchLookup = 2;
  sendSwitch();
}
void updateSwitch3() {
  switchLookup = 3;
  sendSwitch();
}
void updateSwitch4() {
  switchLookup = 4;
  sendSwitch();
}
void updateSwitch5() {
  switchLookup = 5;
  sendSwitch();
}
void updateSwitch6() {
  switchLookup = 6;
  sendSwitch();
}
void updateSwitch7() {
  switchLookup = 7;
  sendSwitch();
}
void updateSwitch8() {
  switchLookup = 8;
  sendSwitch();
}
void updateSwitch9() {
  switchLookup = 9;
  sendSwitch();
}
void updateSwitch10() {
  switchLookup = 10;
  sendSwitch();
}
void updateSwitch11() {
  switchLookup = 11;
  sendSwitch();
}
void updateSwitch12() {
  switchLookup = 12;
  sendSwitch();
}
void updateSwitch13() {
  switchLookup = 13;
  sendSwitch();
}
void updateSwitch14() {
  switchLookup = 14;
  sendSwitch();
}
void updateSwitch15() {
  switchLookup = 15;
#if defined testing
  Serial.print("updateSwitch Triggered by Input on pin:  ");
  Serial.println(switchLookup);
#endif
  sendSwitch();
}
void updateSwitch16() {
  switchLookup = 16;
  sendSwitch();
}
void updateSwitch17() {
  switchLookup = 17;
  sendSwitch();
}
void updateSwitch18() {
  switchLookup = 18;
  sendSwitch();
}
void updateSwitch19() {
  switchLookup = 19;
  sendSwitch();
}
void updateSwitch20() {
  switchLookup = 20;
  sendSwitch();
}
void updateSwitch21() {
  switchLookup = 21;
  sendSwitch();
}
void updateSwitch22() {
  switchLookup = 22;
  sendSwitch();
}
void updateSwitch23() {
  switchLookup = 23;
  sendSwitch();
}
void updateSwitch24() {
  switchLookup = 24;
  sendSwitch();
}
void updateSwitch25() {
  switchLookup = 25;
  sendSwitch();
}
void updateSwitch26() {
  switchLookup = 26;
  sendSwitch();
}
void updateSwitch27() {
  switchLookup = 27;
  sendSwitch();
}
void updateSwitch28() {
  switchLookup = 28;
  sendSwitch();
}
void updateSwitch29() {
  switchLookup = 29;
  sendSwitch();
}
void updateSwitch30() {
  switchLookup = 30;
  sendSwitch();
}
void updateSwitch31() {
  switchLookup = 31;
  sendSwitch();
}
void updateSwitch32() {
  switchLookup = 32;
  sendSwitch();
}
void updateSwitch33() {
  switchLookup = 33;
  sendSwitch();
}
void updateSwitch34() {
  switchLookup = 34;
  sendSwitch();
}
void updateSwitch35() {
  switchLookup = 35;
  sendSwitch();
}



void sendSwitch()
{

  // what switch is this, based on the pinlookup array
  int switchNumber = switchPins[switchLookup]; // this will lookup and store the pin location for this switch -- reinitializing it may be a problem @ compile


#if defined testing
  Serial.print("switchLookup (pin number):  ");
  Serial.println(switchLookup);
  Serial.print("switchNumber (switch number):  ");
  Serial.println(switchNumber);

  if (digitalRead(switchLookup) == LOW) {
   // digitalWrite(BuiltInLED, HIGH);
  } else {
   // digitalWrite(BuiltInLED, LOW);
  }
#endif

  // what layer are we are in based on the currentLayerNumber integer

  // lookup the current key in the current layer
  //  currentkey = layerMatrix[currentLayerNumber][switchNumber];
  currentkeyChar = layerMatrix[currentLayerNumber][switchNumber];

#if defined testing
  Serial.print("currentkeyChar before translation:  ");
  Serial.println(currentkeyChar);
#endif

  for (int i = 0; i < matrixSize1; i++) {
    if (currentkeyChar == translationArrayQMK[i]) {
      wantedpos = i;
      break;
    }
  }
#if defined testing
  Serial.print("wantedpos:  ");
  Serial.println(wantedpos);
#endif
  currentkey = translationArrayDecimal[wantedpos];


#if defined testing
  Serial.print("currentkey after translation:  ");
  Serial.println(currentkey);
#endif

  sendpresses();

}


void sendpresses() {
  if (currentkey >= 256 || currentkey <= 2) {
    switch (currentkey) {
      //------------------------------------------------------//

      case 0:
        if (digitalRead(switchLookup) == LOW) {
          // DO NOTHING  this is an IGNORED KEY
        } else {
          // DO NOTHING  this is an IGNORED KEY
        }
        break;;
      case 1:
        if (digitalRead(switchLookup) == LOW) {
          currentLayerNumber = currentLayerNumber - 1;
        } else {
          currentLayerNumber++;
        }
        break;

      //------------------------------------------------------//

      case 256:
        if (digitalRead(switchLookup) == LOW) {
          // RGB BRIGHTNESS UP
        } else {
          // DO NOTHING
        }
        break;
      case 257:
        if (digitalRead(switchLookup) == LOW) {
          // RGB BRIGHTNESS DOWN
        } else {
          // DO NOTHING
        }
        break;
      case 258:
        if (digitalRead(switchLookup) == LOW) {
          // Cycle through modes, reverse direction when Shift is held
        } else {
          // DO NOTHING
        }
        break;
      case 259:
        if (digitalRead(switchLookup) == LOW) {
          // Toggle RGB lighting on or off
        } else {
          // DO NOTHING
        }
        break;

      // ------------ BEGIN - JOYSTICK BUTTONS ------------//// ------------ BEGIN - JOYSTICK BUTTONS ------------//

      /*
        case 260:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 261:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 262:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 263:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 264:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 265:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 266:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 267:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 268:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 269:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 270:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 271:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 272:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 273:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 274:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 275:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 276:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 277:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 278:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 279:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 280:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 281:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 282:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 283:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 284:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 285:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 286:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 287:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 288:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 289:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 290:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;
        case 291:
        if (digitalRead(switchLookup) == LOW) {
        Keyboard.press();
        } else {
        Keyboard.release();
        }
        break;

      */
      // ------------ END - JOYSTICK BUTTONS ------------//// ------------ END - JOYSTICK BUTTONS ------------//

      // BLUETOOTH - ALSO SEE 397, which is for toggling BLUETOOTH (probably just use it instead of these!)
      case 292:
        if (digitalRead(switchLookup) == LOW) {
          // Toggle USB (vs bluetooth)
        } else {
          // DO NOTHING (?)
        }
        break;
      case 293:
        if (digitalRead(switchLookup) == LOW) {
          // BLUETOOTH
        } else {
          // DO NOTHING (?) - could be a hold to pair, release to stop?
        }
        break;

      //------------------------------------------------------//

      case 294:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_FAST_FORWARD);
        } else {
          Keyboard.release(KEY_MEDIA_FAST_FORWARD);
        }
        break;
      case 295:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_REWIND);
        } else {
          Keyboard.release(KEY_MEDIA_REWIND);
        }
        break;

      //------------------------------------------------------//

      /*
        case 296:
         if (digitalRead(switchLookup) == LOW) {
           Keyboard.press();
         } else {
           Keyboard.release();
         }
         break;
        case 297:
         if (digitalRead(switchLookup) == LOW) {
           Keyboard.press();
         } else {
           Keyboard.release();
         }
         break;
        case 298:
         if (digitalRead(switchLookup) == LOW) {
           Keyboard.press();
         } else {
           Keyboard.release();
         }
         break;
        case 299:
         if (digitalRead(switchLookup) == LOW) {
           Keyboard.press();
         } else {
           Keyboard.release();
         }
         break;
      */
      //------------------------------------------------------//

      case 300:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_PLAY);
        } else {
          Keyboard.release(KEY_MEDIA_PLAY);
        }
        break;
      case 301:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_PAUSE);
        } else {
          Keyboard.release(KEY_MEDIA_PAUSE);
        }
        break;
      case 302:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_RECORD);
        } else {
          Keyboard.release(KEY_MEDIA_RECORD);
        }
        break;
      case 303:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_RANDOM_PLAY);
        } else {
          Keyboard.release(KEY_MEDIA_RANDOM_PLAY);
        }
        break;
      case 304:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_PLAY_SKIP);
        } else {
          Keyboard.release(KEY_MEDIA_PLAY_SKIP);
        }
        break;

      //------------------------------------------------------//

      // Tied to both KC_KB_POWER & KC_PWR
      case 305:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_SYSTEM_POWER_DOWN);
        } else {
          Keyboard.release(KEY_SYSTEM_POWER_DOWN);
        }
        break;
      case 306:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_SYSTEM_SLEEP);
        } else {
          Keyboard.release(KEY_SYSTEM_SLEEP);
        }
        break;
      case 307:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_SYSTEM_WAKE_UP);
        } else {
          Keyboard.release(KEY_SYSTEM_WAKE_UP);
        }
        break;

      //------------------------------------------------------//

      // tied to both KC_KB_MUTE & KC_MUTE
      case 308:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_MUTE);
        } else {
          Keyboard.release(KEY_MEDIA_MUTE);
        }
        break;
      // tied to both KC_KB_VOLUME_UP & KC_VOLU
      case 309:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_VOLUME_INC);
        } else {
          Keyboard.release(KEY_MEDIA_VOLUME_INC);
        }
        break;
      // tied to both KC_KB_VOLUME_DOWN & KC_VOLD
      case 310:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_VOLUME_DEC);
        } else {
          Keyboard.release(KEY_MEDIA_VOLUME_DEC);
        }
        break;
      case 311:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_NEXT_TRACK);
        } else {
          Keyboard.release(KEY_MEDIA_NEXT_TRACK);
        }
        break;
      case 312:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_PREV_TRACK);
        } else {
          Keyboard.release(KEY_MEDIA_PREV_TRACK);
        }
        break;
      case 313:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_STOP);
        } else {
          Keyboard.release(KEY_MEDIA_STOP);
        }
        break;
      case 314:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_PLAY_PAUSE);
        } else {
          Keyboard.release(KEY_MEDIA_PLAY_PAUSE);
        }
        break;
      case 315:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MEDIA_EJECT);
        } else {
          Keyboard.release(KEY_MEDIA_EJECT);
        }
        break;

      //------------------------------------------------------//
      // CUT, COPY, PASTE
      // This could really use a hold feature on the COPY (and maybe CUT) buttons, so when HELD, they paste.  Tap to copy, hold to paste.
      // That would go great on a toggle(d) layer.
      case 316:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_LEFT_CTRL);
          Keyboard.press(120);
        } else {
          Keyboard.release(MODIFIERKEY_LEFT_CTRL);
          Keyboard.release(120);
        }
        break;
      case 317:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_LEFT_CTRL);
          Keyboard.press(99);
        } else {
          Keyboard.release(MODIFIERKEY_LEFT_CTRL);
          Keyboard.release(99);
        }
        break;
      case 318:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_LEFT_CTRL);
          Keyboard.press(118);
        } else {
          Keyboard.release(MODIFIERKEY_LEFT_CTRL);
          Keyboard.release(118);
        }
        break;

      //------------------------------------------------------//
      // F13-F24
      case 319:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F13);
        } else {
          Keyboard.release(KEY_F13);
        }
        break;
      case 320:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F14);
        } else {
          Keyboard.release(KEY_F14);
        }
        break;
      case 321:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F15);
        } else {
          Keyboard.release(KEY_F15);
        }
        break;
      case 322:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F16);
        } else {
          Keyboard.release(KEY_F16);
        }
        break;
      case 323:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F17);
        } else {
          Keyboard.release(KEY_F17);
        }
        break;
      case 324:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F18);
        } else {
          Keyboard.release(KEY_F18);
        }
        break;
      case 325:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F19);
        } else {
          Keyboard.release(KEY_F19);
        }
        break;
      case 326:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F20);
        } else {
          Keyboard.release(KEY_F20);
        }
        break;
      case 327:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F21);
        } else {
          Keyboard.release(KEY_F21);
        }
        break;
      case 328:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F22);
        } else {
          Keyboard.release(KEY_F22);
        }
        break;
      case 329:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F23);
        } else {
          Keyboard.release(KEY_F23);
        }
        break;
      case 330:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F24);
        } else {
          Keyboard.release(KEY_F24);
        }
        break;
      //------------------------------------------------------//
      // F1-F24
      case 331:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F1);
        } else {
          Keyboard.release(KEY_F1);
        }
        break;
      case 332:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F2);
        } else {
          Keyboard.release(KEY_F2);
        }
        break;
      case 333:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F3);
        } else {
          Keyboard.release(KEY_F3);
        }
        break;
      case 334:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F4);
        } else {
          Keyboard.release(KEY_F4);
        }
        break;
      case 335:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F5);
        } else {
          Keyboard.release(KEY_F5);
        }
        break;
      case 336:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F6);
        } else {
          Keyboard.release(KEY_F6);
        }
        break;
      case 337:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F7);
        } else {
          Keyboard.release(KEY_F7);
        }
        break;
      case 338:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F8);
        } else {
          Keyboard.release(KEY_F8);
        }
        break;
      case 339:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F9);
        } else {
          Keyboard.release(KEY_F9);
        }
        break;
      case 340:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F10);
        } else {
          Keyboard.release(KEY_F10);
        }
        break;
      case 341:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F11);
        } else {
          Keyboard.release(KEY_F11);
        }
        break;
      case 342:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_F12);
        } else {
          Keyboard.release(KEY_F12);
        }
        break;

      //------------------------------------------------------//

      case 343:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_PRINTSCREEN);
        } else {
          Keyboard.release(KEY_PRINTSCREEN);
        }
        break;
      case 344:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_SCROLL_LOCK);
        } else {
          Keyboard.release(KEY_SCROLL_LOCK);
        }
        break;
      case 345:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_PAUSE);
        } else {
          Keyboard.release(KEY_PAUSE);
        }
        break;
      case 346:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_INSERT);
        } else {
          Keyboard.release(KEY_INSERT);
        }
        break;
      case 347:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_HOME);
        } else {
          Keyboard.release(KEY_HOME);
        }
        break;
      case 348:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_PAGE_UP);
        } else {
          Keyboard.release(KEY_PAGE_UP);
        }
        break;
      case 349:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_DELETE);
        } else {
          Keyboard.release(KEY_DELETE);
        }
        break;
      case 350:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_END);
        } else {
          Keyboard.release(KEY_END);
        }
        break;
      case 351:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_PAGE_DOWN);
        } else {
          Keyboard.release(KEY_PAGE_DOWN);
        }
        break;

      //------------------------------------------------------//

      // ARROW KEYS (RIGHTT, LEFT, DOWN< UP
      case 352:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_RIGHT);
        } else {
          Keyboard.release(KEY_RIGHT);
        }
        break;
      case 353:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_LEFT);
        } else {
          Keyboard.release(KEY_LEFT);
        }
        break;
      case 354:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_DOWN);
        } else {
          Keyboard.release(KEY_DOWN);
        }
        break;
      case 355:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_UP);
        } else {
          Keyboard.release(KEY_UP);
        }
        break;

      //------------------------------------------------------//
      // keypad
      case 356:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_NUM_LOCK);
        } else {
          Keyboard.release(KEY_NUM_LOCK);
        }
        break;
      case 357:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_SLASH);
        } else {
          Keyboard.release(KEYPAD_SLASH);
        }
        break;
      case 358:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_ASTERIX);
        } else {
          Keyboard.release(KEYPAD_ASTERIX);
        }
        break;
      case 359:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_MINUS);
        } else {
          Keyboard.release(KEYPAD_MINUS);
        }
        break;
      case 360:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_PLUS);
        } else {
          Keyboard.release(KEYPAD_PLUS);
        }
        break;
      case 361:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_ENTER);
        } else {
          Keyboard.release(KEYPAD_ENTER);
        }
        break;
      case 362:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_1);
        } else {
          Keyboard.release(KEYPAD_1);
        }
        break;
      case 363:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_2);
        } else {
          Keyboard.release(KEYPAD_2);
        }
        break;
      case 364:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_3);
        } else {
          Keyboard.release(KEYPAD_3);
        }
        break;
      case 365:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_4);
        } else {
          Keyboard.release(KEYPAD_4);
        }
        break;
      case 366:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_5);
        } else {
          Keyboard.release(KEYPAD_5);
        }
        break;
      case 367:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_6);
        } else {
          Keyboard.release(KEYPAD_6);
        }
        break;
      case 368:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_7);
        } else {
          Keyboard.release(KEYPAD_7);
        }
        break;
      case 369:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_8);
        } else {
          Keyboard.release(KEYPAD_8);
        }
        break;
      case 370:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_9);
        } else {
          Keyboard.release(KEYPAD_9);
        }
        break;
      case 371:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_0);
        } else {
          Keyboard.release(KEYPAD_0);
        }
        break;
      case 372:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEYPAD_PERIOD);
        } else {
          Keyboard.release(KEYPAD_PERIOD);
        }
        break;
      case 373:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_NON_US_BS);
        } else {
          Keyboard.release(KEY_NON_US_BS);
        }
        break;
      case 374:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_MENU);
        } else {
          Keyboard.release(KEY_MENU);
        }
        break;
      case 375:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_CAPS_LOCK);
        } else {
          Keyboard.release(KEY_CAPS_LOCK);
        }
        break;
      case 376:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_QUOTE);
        } else {
          Keyboard.release(KEY_QUOTE);
        }
        break;
      case 377:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_NON_US_NUM);
        } else {
          Keyboard.release(KEY_NON_US_NUM);
        }
        break;
      case 378:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_TAB);
        } else {
          Keyboard.release(KEY_TAB);
        }
        break;
      case 379:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_ENTER);
        } else {
          Keyboard.release(KEY_ENTER);
        }
        break;
      case 380:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(KEY_ESC);
        } else {
          Keyboard.release(KEY_ESC);
        }
        break;
      case 381:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_LEFT_CTRL);
        } else {
          Keyboard.release(MODIFIERKEY_LEFT_CTRL);
        }
        break;
      case 382:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_LEFT_SHIFT);
        } else {
          Keyboard.release(MODIFIERKEY_LEFT_SHIFT);
        }
        break;
      case 383:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_LEFT_ALT);
        } else {
          Keyboard.release(MODIFIERKEY_LEFT_ALT);
        }
        break;
      case 384:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_LEFT_GUI);
        } else {
          Keyboard.release(MODIFIERKEY_LEFT_GUI);
        }
        break;
      case 385:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_RIGHT_CTRL);
        } else {
          Keyboard.release(MODIFIERKEY_RIGHT_CTRL);
        }
        break;
      case 386:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_RIGHT_SHIFT);
        } else {
          Keyboard.release(MODIFIERKEY_RIGHT_SHIFT);
        }
        break;
      case 387:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_RIGHT_ALT);
        } else {
          Keyboard.release(MODIFIERKEY_RIGHT_ALT);
        }
        break;
      case 388:
        if (digitalRead(switchLookup) == LOW) {
          Keyboard.press(MODIFIERKEY_RIGHT_GUI);
        } else {
          Keyboard.release(MODIFIERKEY_RIGHT_GUI);
        }
        break;

        //------------------------------------------------------//
        // This is where we check if it is MO, OSL, TG, TT, and if so treat it appropriately.
        // https://docs.qmk.fm/#/feature_layers?id=switching-and-toggling-layers
        // THIS IS LAYERS (also see 0 and 1)
        /*

          // DF (switches the default layer, not to, but changes what layer is default - probably won't use this)
          case 389:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;

          //  MO(layer) - momentarily activates layer. As soon as you let go of the key, the layer is deactivated.
          case 390:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;

          // OSL(layer) - momentarily activates layer until the next key is pressed. See One Shot Keys for details and additional functionality.
          case 391:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;

          // LM(layer, mod) - Momentarily activates layer (like MO), but with modifier(s) mod active. Only supports layers 0-15 and the left modifiers:
          //  MOD_LCTL, MOD_LSFT, MOD_LALT, MOD_LGUI (note the use of MOD_ constants instead of KC_).
          //    These modifiers can be combined using bitwise OR, e.g. LM(_RAISE, MOD_LCTL | MOD_LALT).
          case 392:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;

          // LT(layer, kc) - momentarily activates layer when held, and sends kc when tapped. Only supports layers 0-15.
          case 393:
          if (digitalRead(switchLookup) == LOW) {
          currentLayerNumber = currentLayerNumber + 1; // this just goes up a layer, which is not what we ultimately want - we want to set the layer to a specific number.
          } else {
          currentLayerNumber--;
          }
          break;

          // TG(layer) - toggles layer, activating it if it’s inactive and vice versa
          case 394:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;

          // TO(layer) - activates layer and de-activates all other layers (except your default layer).
          // This function is special, because instead of just adding/removing one layer to your active layer stack,
          // it will completely replace your current active layers, uniquely allowing you to replace higher layers with a lower one.
          // This is activated on keydown (as soon as the key is pressed).
          case 395:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;

          // TT(layer) - Layer Tap-Toggle. If you hold the key down, layer is activated, and then is de-activated when you let go (like MO).
          // If you repeatedly tap it, the layer will be toggled on or off (like TG). It needs 5 taps by default,
          // but you can change this by defining TAPPING_TOGGLE – for example, #define TAPPING_TOGGLE 2 to toggle on just two taps.
          case 396:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;

              //------------------------------------------------------//
          // TOGGLE Between Bluetooth and USB output
          case 397:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
        */

        //------------------------------------------------------//









        /*
          case 398:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 399:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 400:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 401:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 402:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 403:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 404:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 405:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 406:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 407:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 408:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 409:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 410:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 411:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 412:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 413:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 414:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 415:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 416:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 417:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 418:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 419:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 420:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 421:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 422:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 423:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 424:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 425:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 426:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 427:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 428:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 429:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 430:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 431:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 432:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 433:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 434:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 435:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 436:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 437:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 438:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 439:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 440:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 441:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 442:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 443:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 444:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 445:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 446:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 447:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 448:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 449:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 450:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 451:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 452:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 453:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 454:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 455:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 456:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 457:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 458:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 459:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 460:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 461:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 462:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 463:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 464:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 465:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 466:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 467:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 468:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 469:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 470:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 471:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 472:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 473:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 474:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 475:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 476:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 477:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 478:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 479:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 480:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 481:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 482:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 483:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 484:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 485:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 486:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 487:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 488:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 489:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 490:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 491:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 492:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 493:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 494:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 495:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 496:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 497:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 498:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 499:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 500:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 501:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 502:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 503:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 504:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 505:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 506:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 507:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 508:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 509:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 510:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 511:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 512:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 513:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 514:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 515:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 516:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 517:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 518:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 519:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 520:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 521:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 522:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 523:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 524:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 525:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 526:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 527:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 528:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 529:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 530:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 531:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 532:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 533:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 534:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 535:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 536:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 537:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 538:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 539:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 540:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 541:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 542:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 543:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 544:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 545:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 546:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 547:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 548:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 549:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 550:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 551:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 552:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 553:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 554:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 555:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 556:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 557:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 558:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 559:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 560:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 561:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 562:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 563:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 564:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 565:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 566:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 567:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 568:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 569:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 570:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 571:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 572:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 573:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 574:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 575:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 576:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 577:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 578:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 579:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 580:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 581:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 582:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 583:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 584:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 585:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 586:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 587:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 588:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 589:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 590:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 591:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 592:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 593:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 594:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 595:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 596:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 597:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 598:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
          case 599:
          if (digitalRead(switchLookup) == LOW) {
          Keyboard.press();
          } else {
          Keyboard.release();
          }
          break;
        */
    }
  } else {

    if (digitalRead(switchLookup) == LOW)
    {
      Keyboard.press(currentkey);
#if defined testing
      Serial.println("      PRESS");
#endif
    }
    else
    {
      Keyboard.release(currentkey);
#if defined testing
      Serial.println("      RELEASE");
#endif
    }
  }
}
 
Last edited:
Should just note, going analog in my testing: Either you need a really heavy spring in your switch, or a tactile switch, which would give you a different action to the bump, and then from the bump to bottom-out. I could see it being useful for something, somewhere, but I'm thinking it'd be weird and error-prone in practice. I don't have any tactile switches I can try it with that are compatible with my design, but I may seek out some later. Sadly, budget is maxed out on this project for now.
 
I have a spreadsheet I put together and used to make the arrays, but I'm not quite sure how to post that here. I don't have anything setup to do file hosting at the moment.
Maybe later.

But, this might be useful reference to better understand what is going on.
https://docs.qmk.fm/#/keycodes

The QMK keycodes. If there is an alias, I'm using that. Based on my tests generating configs, they use the alias when one exists. I didn't implement all of them, and they don't have one for all of the options the teensy library has.
I'll figure that out later. The aim was to, after this is done, create an application to generate and send it new configs via rawHID (likely using the decimal keycodes) and keeping all of that in EEPROM. For now though, I'm just making use of the QMK keycodes to make things a bit more human-readable for me, and to get me at least most of the way to a usable drop in array.
 
Back
Top