Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333324

Summary: KeyUp event lost
Product: [Eclipse Project] Platform Reporter: gangliu <clevers594>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: aaron, eclipse.felipe, enochs.brandon, remy.suen
Version: 4.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description gangliu CLA 2010-12-29 21:02:09 EST
Build Identifier: 20100218-1602

If I add a KeyUp listener on some Control, and pressed two keys on it. then only the first KeyUp event can be notified , the next one will be lost for most of keys.

Reproducible: Always

Steps to Reproduce:
1.Add a KeyUp listener on some Control
2.Active this Control, and pressed two keys, for example, 'a' and 's'
3.then then release these keys one by one.
4.check the KeyUp event
Comment 1 Felipe Heidrich CLA 2011-01-04 12:10:32 EST
What are you trying to do ?
Comment 2 gangliu CLA 2011-01-05 20:56:05 EST
(In reply to comment #1)
> What are you trying to do ?

Like the CS game, you can control the move direction by using 'A', 'S', 'D' and 'W'. I want to do something like that.
Comment 3 Missing name CLA 2011-09-18 10:38:43 EDT
The appropriate WM messages are making it to SWT.  However they are some how being filtered by the event loop.
Comment 4 Missing name CLA 2011-09-19 10:06:32 EDT
The problem is on line 1902-1905 of the Widget class.  It returns null from wmKeyUp if display.lastKey == 0.  It appears that the previous wmKeyUp erases the state of lastKey.  It seems like this should be a set of pressed key codes instead of a single value.
Comment 5 Felipe Heidrich CLA 2011-09-19 15:04:58 EDT
(In reply to comment #4)
>  It seems like this should be a set of pressed key codes
> instead of a single value.

That would be just the start for the fix.
The real problem is how to pair a key up with the corrected key down, you can't use the order (as they are different).
Comment 6 Missing name CLA 2011-09-19 15:46:11 EDT
(In reply to comment #5)
> (In reply to comment #4)
> >  It seems like this should be a set of pressed key codes
> > instead of a single value.
> 
> That would be just the start for the fix.
> The real problem is how to pair a key up with the corrected key down, you can't
> use the order (as they are different).

It seems like the order doesn't matter because the key code contains which key was released.
Comment 7 Felipe Heidrich CLA 2011-09-19 16:41:25 EDT
(In reply to comment #6)
> It seems like the order doesn't matter because the key code contains which key
> was released.

not true, try adding some println in the code and you will see
Comment 8 Missing name CLA 2011-09-19 16:44:02 EDT
(In reply to comment #7)
> (In reply to comment #6)
> > It seems like the order doesn't matter because the key code contains which key
> > was released.
> 
> not true, try adding some println in the code and you will see

I added printlns in WM_KEYUP and it works as expected.
Comment 9 Felipe Heidrich CLA 2011-09-19 16:48:32 EDT
(In reply to comment #8)
> (In reply to comment #7)
> > (In reply to comment #6)
> > > It seems like the order doesn't matter because the key code contains which key
> > > was released.
> > 
> > not true, try adding some println in the code and you will see
> I added printlns in WM_KEYUP and it works as expected.

what print and what keys are you testing?
it can work for some simple cases, but it can't make to work all the time.
try some more complex cases
Comment 10 Missing name CLA 2011-09-19 20:19:48 EDT
I'm pressing '+' then '-' then releasing '-' then releasing '+'.  Using Spy++ and debug statements, I'm seeing WM_KEYUP for the right keys.
Comment 11 Eclipse Genie CLA 2019-03-28 01:38:19 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 12 Lars Vogel CLA 2019-10-08 10:50:28 EDT
This bug was marked as stalebug a while ago. Marking as wontfix.

If this report is still relevant for the current release, please
reopen and remove the stalebug whiteboard tag.