Lowering keyboard latency
The easy way to measure latency is with video and even iPhone 11 can capture 240 frames per second, so you’ll be within 5ms of measurement error. 


https://danluu.com/input-lag/


If you have noticeable lag, it’s going to be likely you can use activity monitor to see what is slowing the processor or perhaps detect you have an issue on the USB bus resetting if there’s no obvious reason why keys are buffering and not going directly to the screen.