0

I have been searching for a while now for a library that allows me to know which Key-Event was pressed. But not in a focused program/text-field or anything else but as a process that runs in the background. I'm not trying to write a keylogger but I want to create a program that lets me create shortcuts for key-combinations.

Hardik Vyas
  • 1,973
  • 1
  • 20
  • 43
Paul Sauer
  • 25
  • 2

2 Answers2

1

I don't think Java has native support for something like this. Java is really a language of abstraction, it gets you further away from the OS to make developing easier - but also for security purposes.

Key events are core to the OS so you will (likely) need a language or a library has that capability. Check out JNativeHook.

erik-sn
  • 2,590
  • 1
  • 20
  • 37
  • I allready tried using that library but it failed due to the fact that the 32bit .dll didn't work with my 64bit system. – Paul Sauer Jan 21 '16 at 17:32
0

You can achieve this using JNI and Global System hook. Global System hook applies a Key Logger to the whole computer and not the JVM therefore allowing you to capture key presses outside of the JVM.

An example implementation of it can be seen here

Community
  • 1
  • 1
Dan
  • 7,286
  • 6
  • 49
  • 114