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 12:38 Go to next message
fellowusertoo  is currently offline fellowusertoo Friend
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 318 times)

[Updated on: Sat, 24 September 2011 02: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 12:55 Go to previous messageGo to next message
Lakshmi ShanmugamFriend
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 12: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 09:25 Go to previous messageGo to next message
fellowusertoo  is currently offline fellowusertoo Friend
Messages: 4
Registered: September 2011
Junior Member
*bumps*

[Updated on: Sat, 24 September 2011 02: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] Sat, 24 September 2011 02:47 Go to previous message
fellowusertoo  is currently offline fellowusertoo Friend
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: Fri Nov 28 23:16:40 GMT 2014

Powered by FUDForum. Page generated in 0.05388 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software