Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
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 1804 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  

ivj94 (585 views)
2018-03-24 14:47:39

ivj94 (49 views)
2018-03-24 14:46:31

ivj94 (383 views)
2018-03-24 14:43:53

Solater (63 views)
2018-03-17 05:04:08

nelsongames (110 views)
2018-03-05 17:56:34

Gornova (159 views)
2018-03-02 22:15:33

buddyBro (704 views)
2018-02-28 16:59:18

buddyBro (92 views)
2018-02-28 16:45:17

xxMrPHDxx (494 views)
2017-12-31 17:17:51

xxMrPHDxx (734 views)
2017-12-31 17:15:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!