Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Missing keyborad events
Missing keyborad events [message #464696] Mon, 28 November 2005 21:50 Go to next message
Eclipse UserFriend
Originally posted by: none.none.com

Hi

I have implemented a keyboard listener based on
org.eclipse.swt.events.KeyListener in a SWT application. The program is
a game and i am tracking the keys 'a', 'w', 's' and 's' to move a
character on a canvas.

If i press two keys, and then release them, i seem to only get one call
to the keyReleased() function. Thus my game gets confused and my
character keeps moving even when keys are released.

Is there another way i can inspect the state of the keyboard in SWT
which would be more reliable? Can anyone recommend a proper way to
achieve the desired behavior?

Many regards, Martin.
Re: Missing keyborad events [message #464758 is a reply to message #464696] Tue, 29 November 2005 15:32 Go to previous messageGo to next message
Douglas Pollock is currently offline Douglas PollockFriend
Messages: 84
Registered: July 2009
Member
Martin Bosticky wrote:
> I have implemented a keyboard listener based on
> org.eclipse.swt.events.KeyListener in a SWT application. The program is
> a game and i am tracking the keys 'a', 'w', 's' and 's' to move a
> character on a canvas.
>
> If i press two keys, and then release them, i seem to only get one call
> to the keyReleased() function. Thus my game gets confused and my
> character keeps moving even when keys are released.
>
> Is there another way i can inspect the state of the keyboard in SWT
> which would be more reliable? Can anyone recommend a proper way to
> achieve the desired behavior?

In my experience, KeyUp events in SWT are unreliable. AFAIK, it's not
possible to implement a game of that sort in SWT.



cheers,
d.
Re: Missing keyborad events [message #464764 is a reply to message #464758] Tue, 29 November 2005 16:45 Go to previous message
Eclipse UserFriend
Originally posted by: none.none.com

Douglas Pollock wrote:
> Martin Bosticky wrote:
>
>>I have implemented a keyboard listener based on
>>org.eclipse.swt.events.KeyListener in a SWT application. The program is
>>a game and i am tracking the keys 'a', 'w', 's' and 's' to move a
>>character on a canvas.
>>
>>If i press two keys, and then release them, i seem to only get one call
>>to the keyReleased() function. Thus my game gets confused and my
>>character keeps moving even when keys are released.
>>
>>Is there another way i can inspect the state of the keyboard in SWT
>>which would be more reliable? Can anyone recommend a proper way to
>>achieve the desired behavior?
>
>
> In my experience, KeyUp events in SWT are unreliable. AFAIK, it's not
> possible to implement a game of that sort in SWT.
>
>
>
> cheers,
> d.
>

OK. Sounds like we would need to implement SWT extension to GetKeyState
or GetKeyboardState windows API (and other APIs). I will investigate at
the developers mailing list.

Thanks, martin.
Previous Topic:SWT constant for space key
Next Topic:Table with only 1 column
Goto Forum:
  


Current Time: Thu Mar 28 23:46:16 GMT 2024

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

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

Back to the top