Search code examples
javaswingjframekeylistenerkey-bindings

Highest performance for Keyboard Input


So I have a small java game engine using a single JFrame.

I am currently using Key-Bindings as they were working neatly but I figured that a KeyListener might be architecturally more fitting.

But since I honestly don't really care which I'll use I wanted to ask if there is a performance difference between these or even a better option for getting keyboard input.

Thank you lots for your help!


Solution

  • After my consultation with Turing85 and some testing I figured out that the KeyListener is even up to 1ms faster than the binding.

    ==> If you go for performance KeyListener is your friend.