[Teensy 2.0] Basic question to include a buttonmatrix in joysticksketch

Hello Folks!

I made a modular HOTAS system, seen here Hotas Setup - Album on Imgur and wanted to make
the actual Throttle/Keypad-Thing with the help of a Teensy 2.0 Board.

First i started with using QMK, making a layout, connecting all keys in a matrixconfiguration, and tested that.
All buttons worked just fine.
The way to then get this Keyboard to register as a joystick and edit all the files that are needed for that in a linux environment just brought me from one failure to the next, and so i stepped back from trying that with QMK.

Now i took arduino, made the basic sketch with a keyboard as a matrix, as that was already soldered and perfectly set up, and then made a new sketch with the Joystick CompleteTemplate.

But now im more or less in a comparable situation.

My actual starting point is this:

[ltr]const int numButtons = 18; //setting 18 buttons as the actual desired number

void setup() { // the setup
Serial.begin(9600); //this part i took out of the original template
for (int i=0; i<numButtons; i++) {
pinMode(i, INPUT_PULLUP);
Serial.println(“Begin Complete Joystick Test”);

#define NUMROWS 4 // here i try to define the NUMROWS
#define NUMCOLS 5 // here i try to define the NUMCOLS

byte rowPins[NUMROWS] = {0, 1, 2, 3}; // the rows for my keypad matrix
byte colPins[NUMCOLS] = {20,19,18,17,16}; // the columns for my keypad
// all of course with the correct pinout

byte buttons[NUMROWS][NUMCOLS] = { // here im setting the buttons

void loop() { // were beginning with the loop
// and start with reading 4 axes

// CRAP BEGINS - here i have copied something from a Arduino Micro Pro Sketch,
// which needs a Joystick.h i cant use…


void CheckAllButtons(void) {
if (butbx.getKeys())
for (int i=0; i<LIST_MAX; i++) // Scan the whole key list
if ( buttbx.key[i].stateChanged ) // Only find keys that have changed state
switch (buttbx.key[i].kstate) { // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
case HOLD:
Joystick.setButton(buttbx.key[i].kchar, 1);
case IDLE:
Joystick.setButton(buttbx.key[i].kchar, 0);


// again the manual send

// the check if any button has been pressed
boolean anyChange = false;
for (int i=0; i<numButtons; i++) {
if (allButtons[i] != prevButtons[i]) anyChange = true;
prevButtons[i] = allButtons[i];

// …then send that to the serial monitor
if (anyChange) {
Serial.print("Buttons: ");
for (int i=0; i<numButtons; i++) {
Serial.print(allButtons[i], DEC);

// the delay for running it only 200 times per second

I cant get the matrix-setup to run as i want i to run, obviously because im missing the coding experience to begin with, and some more knowledge about libraries i can and cannot use for this.

Can somebody point me somewhere to solve this puzzle, or has some ideas what i am doing wrong?
Any help is appreciated