Reply – Re: Newt Multimedia keys
Your Name
or Cancel
In Reply To
Re: Newt Multimedia keys
— by mahesh mahesh
for all multimedia keys , KeyCode returned is 0
BTW keypressed is fired for multimedia events, but of no use since we do not know which key was pressed

this is sample program which displays keycode and keychar in console window

 * A program to listen newt keyevents
public class JOGL2NewtDemo {
    private static String TITLE = "JOGL 2 with NEWT";  // window's title
    private static final int WINDOW_WIDTH = 400;  // width of the drawable
    private static final int WINDOW_HEIGHT = 300; // height of the drawable
    private static final int FPS = 60; // animator's target frames per second

     * The entry main() method.
    public static void main(String[] args) {
        // Get the default OpenGL profile, reflecting the best for your running platform
        GLProfile glp = GLProfile.getDefault();
        // Specifies a set of OpenGL capabilities, based on your profile.
        GLCapabilities caps = new GLCapabilities(glp);
        // Create the OpenGL rendering canvas
        GLWindow window = GLWindow.create(caps);

        // Create a animator that drives canvas' display() at the specified FPS.
        final FPSAnimator animator = new FPSAnimator(window, FPS, true);

        window.addWindowListener(new WindowAdapter() {
            public void windowDestroyNotify(WindowEvent arg0) {
                // Use a dedicate thread to run the stop() to ensure that the
                // animator stops before program exits.
                new Thread() {
                    public void run() {
                        if (animator.isStarted())
                            animator.stop();    // stop the animator loop

        window.addKeyListener(new KeyListener(){

			public void keyPressed(KeyEvent e) {
				System.out.println("keycode="+e.getKeyCode()+"  keyChar="+e.getKeyChar());

			public void keyReleased(KeyEvent e) {
				// TODO Auto-generated method stub
          window.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        animator.start();  // start the animator loop