'Get keyboard input from user in java with the program running in background

I once saw a youtube video here and I thought that it would be good exercise to code it myself in java. The Problem is that i can't seem to find a way to read Keyboard input from the user while the program runs in the background, the obvious reason is that it would be dangerous to read the input from the user without the user knowing. I am open for different alternativ ways if there are any.



Solution 1:[1]

Hey I can't find a way to do this in core Java, but here is a github repo you may find useful. It seems to be a global key listener in Java.

Hopefully that GitHub repo helps but use it at your discretion, I'm sure you understand the potential dangers of creating something like this!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kabuto