Open GoogleCodeExporter opened 9 years ago
If anyone else wants to create a new keyboard layout for WindowLicker, here is
a little tool I wrote for easily finding the KeyEvent constants:
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.lang.reflect.Field;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class TestKeyEvent {
public static void main(final String... args) {
JFrame jFrame = new JFrame();
jFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
jFrame.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
try {
int keyCode = e.getKeyCode();
for (Field field : KeyEvent.class.getDeclaredFields()) {
if (!field.getName().startsWith("VK_") || field.getType() != int.class) {
continue;
}
if (keyCode == field.getInt(null)) {
System.out.println(field.getName().substring(3));
}
}
} catch (IllegalArgumentException | IllegalAccessException e1) {
e1.printStackTrace();
}
}
});
jFrame.add(new JLabel("Look a console for output!"));
jFrame.pack();
jFrame.setLocationRelativeTo(null);
jFrame.setVisible(true);
}
}
Original comment by Alexande...@gmail.com
on 25 Sep 2014 at 2:02
Original issue reported on code.google.com by
Alexande...@gmail.com
on 25 Sep 2014 at 1:54Attachments: