     presses[tail] = key;
 }
 
+#define has_press(row) (!digitalRead(KEYPAD_ROW_PIN_BASE + row))
+#define was_pressed(bitmask) (buttons_held & bitmask)
 void handle_interrupt(void) {
     noInterrupts();
     if (action_function == NULL) {

    for (uint8_t i = 0; i != KEYPAD_NUM_ROWS_COLS ; i++) {
        pinMode(KEYPAD_COL_PIN_BASE + i, OUTPUT);
        digitalWrite(KEYPAD_COL_PIN_BASE + i, LOW);
        // TODO unsure if INPUT_PULLUP is digital high with high impedance, needs testing.
        pinMode(KEYPAD_ROW_PIN_BASE + i, INPUT_PULLUP);
        // TODO set to CHANGED and handle multiple buttons!
        attachInterrupt(INTERRUPT_BASE + i, handle_interrupt, FALLING);
    }
}



    for (uint8_t i = 0; i != KEYPAD_NUM_ROWS_COLS ; i++) {
        digitalWrite(KEYPAD_COL_PIN_BASE + i, LOW);
        for (uint8_t j = 0; j != KEYPAD_NUM_ROWS_COLS ; j++) {
            uint16_t bitmask = (1 << (i * 4 + j));
            if (has_press(j) && !was_pressed(bitmask))
                queue_key(buttons[i][j]);
            buttons_held ^= bitmask;
        }
        digitalWrite(KEYPAD_COL_PIN_BASE + i, HIGH);
    }

