Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (744)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (825)
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  
  I didn't believe it but...  (Read 2165 times)
0 Members and 1 Guest are viewing this topic.
Offline krypto

Junior Devvie




while(true) { self.caffeinate (); }


« Posted 2003-10-14 09:06:47 »

When I implemenet keyListener the action of holding a key down appears to be implemented as keyPressed, keyReleased, keyPressed, keyReleased.....
This causes states of my objects to be set when I don't want them to.. i.e. stop player ect. any Ideas??? I'm on win2k.

JRPG Users -  General Users Site
JRPG Developers -  The JRPG Project's Home
Offline Abuse

JGO Ninja


Medals: 60


falling into the abyss of reality


« Reply #1 - Posted 2003-10-14 10:18:46 »

I thought linux was the only platform that suffered from that bug.

I get the expected behaviour in Win98 and XP (don't have a 2K machine to hand)

KeyPressed (n times)
KeyTyped (n times)
KeyReleased (1 time)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
import java.awt.*;
import java.awt.event.*;
public class KeyListenerTest extends Frame implements KeyListener
{
   public KeyListenerTest()
   {
      addKeyListener(this);
      setSize(50,50);
   }
   
   public void keyPressed(KeyEvent e)
   {
      System.out.println(e);
      if(e.getKeyCode()==KeyEvent.VK_ESCAPE) dispose();
   }
   
   public void keyReleased(KeyEvent e)
   {
      System.out.println(e);
   }
   
   public void keyTyped(KeyEvent e)
   {
      System.out.println(e);
   }
   
   public static void main(String [] args)
   {
      new KeyListenerTest().show();
   }
}
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #2 - Posted 2003-10-14 10:26:11 »

Quote
When I implemenet keyListener the action of holding a key down appears to be implemented as keyPressed, keyReleased, keyPressed, keyReleased.....
This causes states of my objects to be set when I don't want them to.. i.e. stop player ect. any Ideas??? I'm on win2k.


Just a shot in the dark, but...could be your BIOS setup. I've always wondered how the hardware typematic-rate interacts with winXXX. ISTR there's normally no problem, but yo may have strange BIOS and/or unusual setting for typematic rate

(it's the BIOS option to simulate the action of holding a key down to make the letter appear lots of times; used to be necessary in the days before OS's/apps that could do that automatically)

malloc will be first against the wall when the revolution comes...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline krypto

Junior Devvie




while(true) { self.caffeinate (); }


« Reply #3 - Posted 2003-10-14 10:29:14 »

Abuse's Test Results on my machine.. I held the down arrow down once then quit.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
DirectDraw surfaces constrained to use vram
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
java.awt.event.KeyEvent[KEY_RELEASED,keyCode=40,keyText=Down,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0

JRPG Users -  General Users Site
JRPG Developers -  The JRPG Project's Home
Offline Abuse

JGO Ninja


Medals: 60


falling into the abyss of reality


« Reply #4 - Posted 2003-10-14 11:06:45 »

Well that is the correct behaviour Krypto Huh

What is the problem?

Set a flag in keyPressed, clear the flag in keyReleased - it should work just fine.
Offline MGodehardt

Junior Devvie




why does the chicken cross the road?


« Reply #5 - Posted 2003-10-14 13:47:02 »

problem is his sync object ( if u dont use a sync object u get in trouble )

so many mutex's
Pages: [1]
  ignore  |  Print  
 
 

 
Ecumene (149 views)
2017-09-30 02:57:34

theagentd (214 views)
2017-09-26 18:23:31

cybrmynd (301 views)
2017-08-02 12:28:51

cybrmynd (288 views)
2017-08-02 12:19:43

cybrmynd (297 views)
2017-08-02 12:18:09

Sralse (291 views)
2017-07-25 17:13:48

Archive (968 views)
2017-04-27 17:45:51

buddyBro (1094 views)
2017-04-05 03:38:00

CopyableCougar4 (1670 views)
2017-03-24 15:39:42

theagentd (1430 views)
2017-03-24 15:32:08
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
java-gaming.org 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‑gaming.org
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!