Let's say that I have window which is not focused.
Is there any other way of catching pressed keys that using KeyListener
.
import javax.swing.JFrame;
public class Main {
public static void main(String[] args) {
Window w = new Window();
}
}
class Window extends JFrame {
private static final long serialVersionUID = -6791503228233798055L;
public JFrame fr;
Window() {
fr = new JFrame();
fr.setVisible(true);
fr.setSize(500, 500);
fr.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
How to catch keys without focused window and KeyListener?