You're testing your keyboard, and you find that some keystrokes are outputting significantly later than when you've pressed them, or perhaps some keys won't output anything at all after you've pressed them. Often, these drops aren't consistent: sometimes keys do work, other times they won't. What's up with that?
Often, these delays have to do with matrix scanning: many times per second, your keyboard will check whether you've pressed anything. Some things can cause these scans to take significantly more time, meaning that your keyboard won't be able to check for keypresses quite as often.
OLED display
OLED displays are processor intensive, but perhaps counter-intuitively, not having an OLED display can cause severe delays. On some keyboards like the Kyria, the OLED is enabled by default. If you're not using a display, your keyboard will seek the display during every scan, and will have to wait on a timeout before continuing. This is a technical problem, but thankfully there's a workaround.
If you don't have an OLED display on your keyboard, check your rules.mk
file and find the following line:
OLED_DRIVER_ENABLE = yes
Then, you should change the line into:
OLED_DRIVER_ENABLE = no
Afterwards, flash both sides of your split keyboard. The latency issue should have been resolved by this.
Custom code
Latency can also be caused by custom code. If you're performing calculations during scanning, such as in the matrix_scan_user
function, you should check if removing this code has any effect on the latency. If it does, you may want to alter your code to not execute during any scan. You can do that by wrapping your code in an if statement:
uint8_t counter = 0;
void matrix_scan_user(void) {
// You can adjust '5' to execute your code every nth scan.
if (counter % 5 == 0) {
counter = 0;
// TODO: place your custom code here
}
counter++;
}
Performing code during scanning may not be desirable because of the impact it can have on performance. Feel free to experiment, as that's where cool stuff comes from, but know about the possible impact on performance and how to work around it.
Other causes
If you've tried either of the above and couldn't find the cause, please reach out to us. The best way is to join our Discord server and ask on the #help channel.