Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (710)
Games in Android Showcase (212)
games submitted by our members
Games in WIP (784)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  SWT keyReleased Problem.  (Read 1582 times)
0 Members and 1 Guest are viewing this topic.
Offline JoshuaD

Senior Newbie

Java games rock!

« Posted 2006-03-10 18:34:31 »


I'm writting a tetris game in Java/SWT. 

When I hold down two keys, and then release one, that key release isn't sent to my KeyListener.

Example:  I hold down "drop", I hold down "move left", I let go of "drop", I let go of "move left".

We would expect that it would be neither dropping or moving left.  However, it doesn't stop dropping. 

here's my keyReleased code.  It's pretty simple, so I don't think it's the problem, but I'll include it anyway.

public void keyReleased(KeyEvent e) {
   int value = e.keyCode;
   if( value == lMoveLeft )          game1.stopMovingLeft();
   if( value == lMoveRight )         game1.stopMovingRight();
   if( value == lDrop )             game1.stopDropping();
   if( value == rMoveLeft )          game2.stopMovingLeft();
   if( value == rMoveRight )         game2.stopMovingRight();
   if( value == rDrop )             game2.stopDropping();

It was originally an if..else if.. else if chain, but I took out the else's to make sure those weren't somehow causing the problem.

It's not any of the function calls I'm making in there, because it never gets that far. ( I checked with printlns)
What's most strange about this bug is that it doesn't occur if I'm using the arrow buttons.  I can hold as many as I want and release them however and it works exactly how I would expect. 

It does happen when I use any letter key though.  I haven't tested for anything but the 4 arrows and the 26 letters.

Does anyone know how I can fix this?  Is this a bug or a feature? 

Any help is appreciated.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

numerical (21 views)
2017-02-21 07:32:16

numerical (21 views)
2017-02-21 07:31:46

theagentd (130 views)
2017-02-18 13:42:33

theagentd (133 views)
2017-02-18 13:35:16

h.pernpeintner (1297 views)
2017-01-24 22:39:11

h.pernpeintner (1285 views)
2017-01-24 22:38:32

Galdo (1845 views)
2017-01-12 13:44:09

Archive (1946 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2485 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2305 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!