Question

My title basically tells my goal. I would like to get some sort of keyboard input, be it an event or just plain text, using java in a headless environment. I believe there is a file in /dev that registers all keyboard events, but i don't know exactly the file name, nor if there is any special encoding around the file to read from it.

Was it helpful?

Solution

You probably mean "text-only" rather than "headless", since you're apparently looking for interactive input. If using standard input isn't good enough, consider using a curses library like JCurses. You could theoretically use the /dev/eventX files, but you're going to run into lots of permissions and contention problems, and your program will be 100% non-portable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top