Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Why isn't key released event sent when two keys are pressed?
Why isn't key released event sent when two keys are pressed? [message #724036] Sat, 10 September 2011 08:38 Go to next message
fellowusertoo  is currently offline fellowusertoo
Messages: 4
Registered: September 2011
Junior Member
The following code works when you press single keys.

@Override public void handleEvent(Event evt) {
    switch(evt.type) {
    case SWT.KeyDown:
        System.out.println(evt.keyCode + " pressed");
        break;

    case SWT.KeyUp:
        System.out.println(evt.keyCode + " released");
        break;
    }
}

...

widget.addListener(SWT.KeyDown, this);
widget.addListener(SWT.KeyUp, this);


But when you press multiple keys like "A" first then "B", the listener will only receive key up event for "B" and no events for "A". So as a result, ...

switch(evt.type) {
case SWT.KeyDown:
    mKeyMap.get(evt.keyCode).isDown = true;
    break;

case SWT.KeyUp:
    mKeyMap.get(evt.keyCode).isDown = false;
    break;
}


The key "A" will always remain true, until you press it again and receive key down event and key up event. This problem doesn't happen with the arrow keys though. You can press multiple arrow keys and it sends key up events correctly.

So, why isn't key released event sent for key "A" when keys "A" and "B" are pressed?

Graphical Example:
index.php/fa/4057/0/

Note, my platform is Windows 7 64-bit. Eclipse 3.6.2 (Build: M20110210-1200). SWT 3.7 Final Release (13 June 2011). Tried SWT 3.8 M2 (16 September 2011) as well.

I have tried 5 different keyboards and on my other laptop (which is running Windows 7 64-bit as well). Definitely not a keyboard issue.

More importantly, how do I get over this problem?
.
.
.
Is this a bug?

Thanks a lot!
  • Attachment: screen.png
    (Size: 88.03KB, Downloaded 298 times)

[Updated on: Fri, 23 September 2011 22:46]

Report message to a moderator

Re: Why isn't key released event sent when two keys are pressed? [message #724482 is a reply to message #724036] Mon, 12 September 2011 08:55 Go to previous messageGo to next message
Lakshmi Shanmugam
Messages: 274
Registered: July 2009
Location: India
Senior Member
The KeyUp event should be sent for both the keys when they are released. I added a KeyListener to a Text control and I get the KeyUp events correctly.
Which platform/OS are you using? Which version of eclipse?


Lakshmi P Shanmugam

[Updated on: Mon, 12 September 2011 08:55]

Report message to a moderator

Re: Why isn't key released event sent when two keys are pressed? [message #725954 is a reply to message #724482] Fri, 16 September 2011 05:25 Go to previous messageGo to next message
fellowusertoo  is currently offline fellowusertoo
Messages: 4
Registered: September 2011
Junior Member
*bumps*

[Updated on: Fri, 23 September 2011 22:47]

Report message to a moderator

Re: Why isn't key released event sent when two keys are pressed? [message #728838 is a reply to message #725954] Fri, 23 September 2011 22:47 Go to previous message
fellowusertoo  is currently offline fellowusertoo
Messages: 4
Registered: September 2011
Junior Member
*bumps*
Previous Topic:Calling .NET DLL method from SWT java
Next Topic:Windows 7 Directory Dialog Issues
Goto Forum:
  


Current Time: Thu Jul 24 02:27:07 EDT 2014

Powered by FUDForum. Page generated in 0.02024 seconds