Login  Register

NEWT KeyEvent Function Key Trouble

Posted by Jake on Dec 08, 2013; 8:10pm
URL: https://forum.jogamp.org/NEWT-KeyEvent-Function-Key-Trouble-tp4030828.html

I'm trying to make a simple input control using NEWT so that pressing F9 sets my GLWindow to fullscreen and F12 destroys the window.

Here is my code:

            while( null != ( event = (NEWTEvent) eventFifo.get() ) ) {
                Window source = (Window) event.getSource();
         
                if(event instanceof KeyEvent) {

                    KeyEvent keyEvent = (KeyEvent) event;
                   
                    switch(keyEvent.getKeyCode()) {

                    case KeyEvent.VK_F9:
                            source.setFullscreen(!source.isFullscreen());
                            break;

                    case KeyEvent.VK_F12:
                            shouldQuit = true;
                            break;
                    }
                }
            }

The problem is the if clause returns false whenever I hit a function key but true if I type anything else(a-z). However I still receive the following output for function keys:

KeyEvent[EVENT_KEY_PRESSED, code 0x69, sym 0x69, char ' ' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1386532337539 d 0ms]]]

KeyEvent[EVENT_KEY_RELEASED, code 0x69, sym 0x69, char ' ' (0x0), printable false, modifier false, action true, InputEvent[modifiers: [], NEWTEvent[source:jogamp.newt.driver.windows.WindowDriver, consumed false, when:1386532337753 d 0ms]]]

I also tried outputting the value of event.getEventType() for a-z keys and function keys. a-z yields a result of 301 which is a KeyEvent but the function keys didn't output anything. This was done using System.out.println(event.getEventType())

Any help would be appreciated and sorry if I'm just doing something dumb, I'm still rather new to this.