Dylan Wheeler
Dylan Wheeler

Reputation: 7074

Java KeyEvent and KeyListener

Is the Java KeyListener universal meaning that it will work for any application that I type into?

If not, how can I make it universal?

Upvotes: 0

Views: 392

Answers (2)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285403

Please define "universal". Do you mean will it work as a key-logger? Answer: no. For that you'd need to write a key board hook that would be plugged into the operating system, something that can be done with Java via JNI or JNA, but something that Java is not well suited for.

Upvotes: 1

Jeffrey
Jeffrey

Reputation: 44808

It is not universal. It only works if the component you registered it for has focus. You can use keyboard hooks to make it universal, but you will either have to use JNI or JNA to integrate the native code.

Upvotes: 2

Related Questions