How to capture keyboard event without Enter key in

2019-07-28 22:52发布

问题:

I'm writing a game based on terminal and I want capture keyboard event, such as w/a/s/d as direction of Up/Left/Below/Right, rather then readLine a input stream with a Enter key.

Besides, I have read swing package, it has some KeyListener interface but it seems must bind with swing UI.

Does there have pure keyboard event without other technology binding in java world?