0

I've been searching a while for a way my code could check for Keystrokes while another window is active. For eg. while I'm writing on word and then I could press a combination of keys to trigger something in my code. But the only thing I was able to find on the internet is KeyListener, witch is great but unfortunally only cheks for Keystrokes while the last thing you interacted with is a JFrame, Frame, TextField...(same thing with MouseListener) I want a way to check for Keystrokes no matter what my last interaction was. I hope any of you guys can help me.

Teddy
  • 1
  • Any solution will be OS-specific, since you're trying to do something that requires making OS calls. – Hovercraft Full Of Eels Jul 30 '22 at 11:36
  • Well I'm on windows. So I would need a solutiion for windows. – Teddy Jul 30 '22 at 11:47
  • Then check out the answers in the duplicate. Also, to search Google better, perhaps use the term "key logger" because that is what you want. Also note that there is no simple Java solution to this type of problem as Java has been built to be as OS-agnostic as possible, and so it tries to avoid letting coders get close to "the metal", the OS and hardware. To solve this will require that you delve into more advanced programming concepts, including possibly using JNI or JNA. – Hovercraft Full Of Eels Jul 30 '22 at 11:49
  • Thank you so much! I've been searching for hours for a solution so thank you – Teddy Jul 30 '22 at 11:56
  • You're welcome. I don't know you or your skill ability, but I've been doing Java for over 30 years, and doing this sort of project would be daunting for me. Perhaps it will be easier for you. – Hovercraft Full Of Eels Jul 30 '22 at 11:58

0 Answers0