Multiple key events during high workload

Hi,
When my machine is busy it happens that letters get repeated, something like `baaad' with the input of `bad'. Is this a known problem? Is it hardware related? Is it OS related? Is it fixed in Leopard?
I worked on Linux before and I never had such problems with Linux.
By the way, when my MacBook Pro ejects the disc the rest of the machine does not respond to anything ...
Best wishes
Stefan

You can adjust the key rate via System Preferences>Keyboard & Mouse>Keyboard.

Similar Messages

  • Getting Key Events during animation loop

    I'm having a problem recieving Key events during my animation loop. Here is my example program
    import java.awt.*;
    import java.awt.image.BufferStrategy;
    import javax.swing.JPanel;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import java.util.ArrayList;
    import java.awt.event.*;
    import java.util.Iterator;
    import GAME.graphics.Animation;
    import GAME.sprites.MainPlayer;
    import GAME.util.MapData;
    import GAME.input.*;
    public class ImageTest extends JFrame {
        private static final long DEMO_TIME = 20000;
        private Animation      anim;
        private MainPlayer     mPlayer;
        private MapData               mapData;
        private InputManager      inputManager;
        private GameAction moveLeft;
        private GameAction moveRight;
        private GameAction exit;
        public ImageTest()
         requestFocus();
         initInput();
         setSize(1024, 768);
         setUndecorated(true);
         setIgnoreRepaint(true);
         setResizable(false);
         loadImages();
         anim = new Animation();
            mPlayer = new MainPlayer(anim);
            setVisible(true);
            createBufferStrategy(2);
            animationLoop();
         // load the player images
         private void loadImages()
              // code that loads images...
         // Initialize input controls
         private void initInput() {
            moveLeft = new GameAction("moveLeft");
            moveRight = new GameAction("moveRight");
            exit = new GameAction("exit",
                GameAction.DETECT_INITAL_PRESS_ONLY);
            inputManager = new InputManager(this);
            inputManager.setCursor(InputManager.INVISIBLE_CURSOR);
            inputManager.mapToKey(moveLeft, KeyEvent.VK_LEFT);
            inputManager.mapToKey(moveRight, KeyEvent.VK_RIGHT);
            inputManager.mapToKey(exit, KeyEvent.VK_ESCAPE);
        // Check player input
        private void checkInput(long elapsedTime) {
            if (exit.isPressed()) {
                System.exit(0);
            if (mPlayer.isAlive()) {
                float velocityX = 0;
                if (moveLeft.isPressed()) {
                    velocityX-=mPlayer.getMaxSpeed();
                if (moveRight.isPressed()) {
                    velocityX+=mPlayer.getMaxSpeed();
                mPlayer.setVelocityX(velocityX);
        // main animation loop
        public void animationLoop() {
            long startTime = System.currentTimeMillis();
            long currTime = startTime;
            while (currTime - startTime < DEMO_TIME) {
                long elapsedTime =
                    System.currentTimeMillis() - currTime;
                currTime += elapsedTime;
                checkInput(elapsedTime);
                mPlayer.update(elapsedTime);
                // draw and update screen
                BufferStrategy strategy = this.getBufferStrategy();
                Graphics2D g = (Graphics2D)strategy.getDrawGraphics();
                if (!(bgImage == null))
                     draw(g);
                     g.dispose();
                     if (!strategy.contentsLost()) {
                         strategy.show();
                // take a nap
                try {
                    Thread.sleep(20);
                catch (InterruptedException ex) { }
        public void draw(Graphics g) {
            // draw background
            if (bgImage != null)
                         // draw image
                 g.drawImage(mPlayer.getImage(), (int)mPlayer.getX(), (int)mPlayer.getY(), null);
    }My InputManager implements KeyListener. When running print statements on my Key events, they are not being called until after the animation demo is done running. Can someone help me with getting the Key events to update during the animation loop? Thank you!

    I've used the post from Abuse on the following thread with success. Maybe it will clue you in to what you might be doing wrong:
    http://forum.java.sun.com/thread.jsp?forum=406&thread=498527

  • Javafx multiple key events

    I have created a program in which a scene have two objects, and each object reacts when certain key is pressed, for example, when 1 is pressed , object 1 prints it's state,a and when 2 is pressed object 2 reports its state, but the program only work for object which is declared first in the scene
    following is an illustration
    import javafx.scene.input.KeyEvent;
    import javafx.scene.Scene;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    * @author Vaibhav
    Stage{
        scene: Scene{
            content: [
                Rectangle{
                    onKeyPressed: function(ex:KeyEvent):Void{
                        println('first rectangle');
                Rectangle{
                    onKeyPressed: function(ex:KeyEvent):Void{
                        println('Second rectangle');
    }but it prints only for fist rectangle , is there a workaround

    Only the object, which has the focus, can react on key events. Apparently in your case the first object has the focus, therefore the second one does not receive the events. You can set the focus manually with requestFocus().

  • RemoteApp receives multiple KeyUp events without any keys being pressed

    Hi All,
    I have a very simple winforms app that I am using to try and track down what is happening with keyboard events when using RemoteApp.
    Basically I have a form and a textbox that track the KeyDown, KeyPress and KeyUp events.
    As soon as I start my app via RemoteApp I receive multiple KeyUp events without even pressing a key.
    Does anyone know why RemoteApp would be sending these random KeyUp events.
    The code of my simple test app is as follows:
    Public Class Form1
    Dim lst As New List(Of String)
    Private Sub AddtoList(str As String)
    lst.Add(str)
    End Sub
    Private Sub TextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    AddtoList("txt KeyDown" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    AddtoList("txt KeyPress" & vbTab & "KeyChar is " & e.KeyChar)
    End Sub
    Private Sub TextBox1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
    AddtoList("txt KeyUp" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    AddtoList("Form Closing")
    IO.File.AppendAllLines(Application.StartupPath & "\SimpleKeyUp_v2.txt", lst)
    End Sub
    Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    AddtoList("Form KeyDown" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub Form1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
    AddtoList("Form KeyPress" & vbTab & "KeyChar is " & e.KeyChar)
    End Sub
    Private Sub Form1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
    AddtoList("Form KeyUp" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    AddtoList("Form Load")
    End Sub
    End Class
    Simply opening and closing the app via RemoteApp gives the following results:
    Form Load
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form KeyUp KeyCode is 16
    txt KeyUp KeyCode is 16
    Form KeyUp KeyCode is 16
    txt KeyUp KeyCode is 16
    Form KeyUp KeyCode is 17
    txt KeyUp KeyCode is 17
    Form KeyUp KeyCode is 17
    txt KeyUp KeyCode is 17
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form KeyUp KeyCode is 18
    txt KeyUp KeyCode is 18
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form KeyUp KeyCode is 18
    txt KeyUp KeyCode is 18
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form Closing
    Cheers and Thanks in Advance!
    Dwayne

    Hi,
    It seems that your issue has been out of the scope of this forum.For coding issue,I suggest you ask in the
    MSDN forum to see whether anyone can help you out.
    Regards,
    Clarence
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Am I able to tag a data point of a spreadsheet that is being created by a datalogging VI such that at the end I have the data with multiple tags which corelate to events during a measurement cycle

    Am I able to tag a data point of a spreadsheet that is being created by a datalogging VI such that at the end I have the data with multiple tags which corelate to events during a measurement cycle
    My final need is to take data from a datalogging VI and store it in a spreadsheet with tags that corespond to events in a subVI which is controlling motor movement. This will allow users to view all data and mark the relevent data for analysis. As usual, user want everthing but with conditions.

    Sure. What you do is take the numeric value acquired, the tags you want, and build them into an array. So now, when you write to the spreadsheet, you'll have a 2D array. One thing you have to keep in mind is that all elements of an array have to be of the same type. So if your tags are strings, you'll have to convert your numeric data into strings as well.

  • Unable to find Key Events when there are multiple Commands

    Hi,
    I've developed a simple J2ME Appln containing 3 commands
    for ex- Exit,Help and Info(all with same priority).
    As there are 3 commands, Exit command is present at the left and the other two namely Help and Info have been listed under Menu and this Menu command is presented at the right.
    My MIDlet class has extened MIDlet and implemented CommandListener. Using CommandAction(), I'm able to generate action for Command press and i've also created a nested class which extends Canvas so, using keyPressed and keyReleased, I'm able to find the Key Press Events.
    Now, my appln needs to find just the key press events. After i press the Menu command, the two commands namely Help and Info are listed. In tht screen, I need to find out whether any other key events are being generated but my keyPressed and keyReleased are not being called.
    Please provide me solution ASAP.

    I'm going to make a few assumptions:
    1. The menu you're describing is the automatically generated one caused by having more than two commands.
    2. The subclass of Canvas is the currently active Displayable (otherwise you won't get any key events at all).
    If this is the case (and someone correct me if I'm wrong), key events are being handled by the phone's subsystem to drive the menu, which means there's no way to get them. The way I've approached this kind of problem is to create my own menu painting and handling code and incorporated it into the Canvas. Then, make one Command called 'Menu' and have it invoke your custom menu code.
    I realise this isn't an ideal solution, but it's something.

  • KEY events in MIDlets

    Hello all,
    I am basically new to J2ME MIDP development and also new to this
    forum. So apologies if this has already been covered or turns out to
    be a stupid question :) Here goes:
    I am trying to develop a MIDlet where I have a Form to accept certain
    values from the user. This is fairly straightforward and is easy to
    create with the high level Form a and TextField objects.
    Now, I wish to add a functionality to my MIDlet, in which, the user
    can press a specific key.. say the "Select" key or the "Call" key.. at
    any time during the form to start another thread of operation which
    performs something totally different... say for example, the user is
    entering values into the form and in between somewhere he presses this
    specific key and the phone start playing music. I hope you get my
    point.
    Basically I want to listen for key pressed or key held events on a
    Form object. Now I understand that Key events can be found only on the
    low-level Canvas based UIs. So is it possible to do it with Screen class
    elements..?
    Thanks,
    Nik

    You can try to use a CustomItem. What events will be delivered to the custom item depends on the implementation, though. Also these events will be only delivered when the CustomItem is focused.
    Have a look at the J2ME Polish GUI for using CustomItems for MIDP/1.0 devices as well.
    http://www.j2mepolish.org
    Best regards,
    Robert

  • Macbook misses some key events for a few seconds

    I have noticed that for last two months or so something strange happens to my Retina MBP. Once in a couple of days it stops responding to some key events. It is like it handles only one keypress out of 4-5. Nothing seems to be wrong with the keyboard and it is not about a particular key or keys. And about 10-15 seconds later everything goes back to normal. I do not see any suspicious messages in the logs, the computer is connected to the power supply...It happens just by itself in the middle of the day, when I am typing.
    Almost looks like some interrupts get lost by the system while it is busy with something else. But I have checked the load level and running processes - nothing interesting there....And whatever it is - it happens during a very short period of time.

    Hi,
    No, I have not returned my MBP yet. In fact, I would rather avoid doing this unless I am convinced if it is a hardware issue. And I do believe it is not. Just recently I have spent some time investigating it and I have found very stroing correlation between the moments when this happens and these messages in the kernel log:
    Jan 13 10:49:54 mbp-wifi kernel[0]: Sandbox: sandboxd(96471) deny mach-lookup com.apple.coresymbolicationd
    Jan 13 10:54:31 mbp-wifi kernel[0]: Sandbox: sandboxd(96499) deny mach-lookup com.apple.coresymbolicationd
    Jan 13 10:54:31 mbp-wifi.home sandboxd[96499] ([96497]): mdworker(96497) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:54:31 mbp-wifi.home sandboxd[96499] ([96498]): mdworker(96498) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:56:32 mbp-wifi.home sandboxd[96504] ([96503]): mdworker(96503) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:56:32 mbp-wifi.home sandboxd[96504] ([96502]): mdworker(96502) deny mach-lookup com.apple.ls.boxd
    And I have also noticed that my Spotlight database gets reconstructed too often, which means it gets corrupted.
    From all this I conclude that it is most likely the software issue and it seems to be linked to spotlight. I saw people reporting similar things. So now I am researching on how to fix it without disabling the spotlight.
    In general, I believe that the quality of Apple software is going down, it is not like 4-5 years ago And Apple does seem to care less and less about it.
    If in your case it happens all the time, not just once in a while, and you see that a particular key has problems - it is possible that we are talking about the different issues and yours might be really about the keyboard.

  • How to get Multiple Key Combinations

    Hi,
    I am trying to get the event for multiple key combinations, ie some thing like "*Ctrl + I + M*" or "*Alt + A + S + D*".
    For two key combinations ( like Ctrl+I or Ctrl+M) i am able to get, but for more than two keys combinations, can someone give an idea how to get it.
    I tried with both KeyCodeCombination and KeyCharacterCombination.
    Below is a quick example to check for the key combination demo.
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.input.KeyCharacterCombination;
    import javafx.scene.input.KeyCode;
    import javafx.scene.input.KeyCodeCombination;
    import javafx.scene.input.KeyCombination;
    import javafx.scene.input.KeyEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    public class KeyCombinationDemo extends Application {
         Stage stage;
         Scene scene;
         StackPane root;
         public static void main(String[] args) {
              Application.launch(args);
         @Override
         public void start(Stage stage) throws Exception {
              this.stage = stage;
              root = new StackPane();
              root.getChildren().add(new Label("Enter any Key"));
              this.scene = new Scene(root, Color.LINEN);
              stage.setTitle(this.getClass().getSimpleName());
              stage.setWidth(600);
             stage.setHeight(600);
             stage.setScene(this.scene);
             stage.show();
              final KeyCombination keyComb1=new KeyCodeCombination(KeyCode.I,KeyCombination.CONTROL_DOWN);
              final KeyCharacterCombination keyComb2 = new KeyCharacterCombination("M",KeyCombination.CONTROL_DOWN);
              this.scene.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {
                   @Override
                   public void handle(KeyEvent event) {
                        if(keyComb1.match(event)){
                             System.out.println("Ctrl+I pressed");
                        }else if(keyComb2.match(event)){
                             System.out.println("Ctrl+M pressed");
    }Thanks in Advance.
    Regards,
    Sai Pradeep Dandem.

    Hi John,
    Thanks for the prompt response.
    I tried the way you suggested and it worked well !! Thanks :)
    But, still i am expecting a direct way to handle this. :p
    Anyway here is code which i modified accordingly
    final String keyCombination1 = "_ALT_E_O";
    final String keyCombination2 = "_ALT_E_P";
    final String keyCombination3 = "_CONTROL_H";
    final StringBuilder key = new StringBuilder();
    this.scene.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
         @Override
         public void handle(KeyEvent event) {
              String codeStr = event.getCode().toString();
              if(!key.toString().endsWith("_"+codeStr)){
                   key.append("_"+codeStr);
    this.scene.addEventHandler(KeyEvent.KEY_RELEASED, new EventHandler<KeyEvent>() {
         @Override
         public void handle(KeyEvent event) {
              if(key.length()>0){
                   if(key.toString().equals(keyCombination1)){
                        System.out.println("Key Combination 1 pressed");
                   }else if(key.toString().equals(keyCombination2)){
                        System.out.println("Key Combination 2 pressed");
                   }else if(key.toString().equals(keyCombination3)){
                        System.out.println("Key Combination 3 pressed");
                   key.setLength(0);
    });Thanks & Regards,
    Sai Pradeep Dandem

  • Multiple key level associations

    Hi,
    I am getting the below error during the consistency check.
    Table, X, has multiple key level associations.
    Can anyone please let me know the reason for the same.
    Also, when I drag the physical tables from the physical layer to the BMM Layer, there are some default primary keys in the Logical Table.What considerations does OBIEE take into when deciding upon the Primary Key in the Logical table.
    Thanks in Advance
    Akshatha

    "can you check the keys foreign keys for those table "
    You didn't mention what I should be checking for.
    However, I think I've worked it out now.
    I have a dimension table that is referenced by both other dimension tables and the fact tables. Therefore, when imported into BI, both the dimension tables and the fact tables have foreign keys to this common dimension table.
    I'm guessing that the foreign keys on the dimension tables are not required - because there are foreign key references from the fact tables to the common table anyway. Bearing in mind that this is a star schema and not a snowflake schema.
    => I deleted all the foreign keys from all my dimension tables, and now the consistency check works ok.

  • Lag on key press (key event)

    Hello, I am currently working on a simple game in Java. I've used Java's Key_Pressed in Key Event to control a ship moving back and forth with the up and down keys. I've noticed that when a key is pressed there is a short pause before the ship actually moves. What can I do to avoid this pause?

    The "repeat rate" for holding a key down is controlled by the OS.
    You should not be relying on multiple KeyEvents to move your component as the repeat rate will vary from machine to machine. Actually you should not be using KeyEvents anyway you should be using [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]Key Bindings
    On keyPressed binding you would start a Timer and then on keyReleased you stop the Timer. You can then control the interval at which the Timer fires so you game will be consistent on all machines.

  • Thinkpad keyboard problem - some keys generate multiple keys when pressed

    thinkpad keyboard problem - some keys generate multiple keys when pressed
    For example, "t" generates "tr", "y" generates "yu", "backspace" generates "backspace" plus "IBM access connections", "m" generates "mn" and "n" generates "mn".  Not all keys are wrong. 
    For what it's worth, the odd behaviour started shortly after a trip to Miami in which I had a meeting at a cafe in which we were undercover but it was pouring cats and dogs - it was like having a meeting in a sauna - so I am wondering if the high humidity could have caused the behaviour.
    I tried replacing the keyboard but the new keyboard has the same problem.  
    The machine in question is a Thinkpad T23 running Windows XP Pro
    Any help would be appreciated as I am now in Los Angeles using a borrowed Mac! :-) 

    i have something along the lines of the same problem.
    http://bbs.archlinux.org/viewtopic.php?id=56777
    my conclusion is something in the last system update screwed it up.

  • Time Evaluation with multiple time events

    Dear Friends,
    I have an issue in our current project. Kindly try to help me with a solution.
    We are working on Time Management module with Positive Time Recording method and evaluation- India. (Payroll module is not implemented)
    My issue is:
    Evaluation with multiple time events in a day: In our project, we have a scenario like the employees record multiple clock in and clock out times for one day and are uploaded into infotype 2011. But during time evaluation, only first Time event that is P10 (Clock In) and the last Time event P20 (Clock-out) in a day should be considered for evaluation, ignoring any multiple time entries in between duration in the table TEVEN (Infotype 2011).
    Pls let me know how this requirement can be met. Do we need to define any new PCR’s or create any functions? If yes, pls tell me the process in detail as I am new and implementing Time management (Positive Time recording with Evaluation) for first time. Try to help me as soon as possible.
    Thanks & Regards,
    Chiranjeevi
    Edited by: chiran reddy on Feb 15, 2008 2:20 PM

    is it not possible to enter only the first p10 and last p20 from the time systems into 2011.

  • IsKeyDown - Multiple key detection ?

    does anyone know of how to read two keys or check two keys are down/pressed?
    I am trying to do a game where the object can mover diagonally so i need the game to react differently if 2 cursor keys are down?
    Any ideas about the isKeyDown() function?
    The keypressed/ keyreleased function i think will only detect one at a time.
    cheers all

    Try this quick Swing App I knocked up using Sun One. It shows multiple key detection, doesn't mind simultaneous key presses.
    I wrote the code for clarity more than anything else.
    Run it, see what it does and how it reacts to the cursor keys being pressed.
    * KeyEvents.java
    * Created on 05 December 2002, 16:21
    package andy.apps.KeyEvents;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class KeyEvents extends javax.swing.JFrame {
        /** Creates new form KeyEvents */
        public KeyEvents() {
            initComponents();
            upPanel.registerKeyboardAction(new UpOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
            upPanel.registerKeyboardAction(new UpOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
            downPanel.registerKeyboardAction(new DownOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
            downPanel.registerKeyboardAction(new DownOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
            leftPanel.registerKeyboardAction(new LeftOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
            leftPanel.registerKeyboardAction(new LeftOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
            rightPanel.registerKeyboardAction(new RightOnListener(), KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), JComponent.WHEN_IN_FOCUSED_WINDOW);
            rightPanel.registerKeyboardAction(new RightOffListener(), KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, true), JComponent.WHEN_IN_FOCUSED_WINDOW);
        class UpOnListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.upPanel.setBackground(Color.black);
        class UpOffListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.upPanel.setBackground(Color.white);
        class DownOnListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.downPanel.setBackground(Color.black);
        class DownOffListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.downPanel.setBackground(Color.white);
        class LeftOnListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.leftPanel.setBackground(Color.black);
        class LeftOffListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.leftPanel.setBackground(Color.white);
        class RightOnListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.rightPanel.setBackground(Color.black);
        class RightOffListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                KeyEvents.this.rightPanel.setBackground(Color.white);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        private void initComponents() {
            upPanel = new javax.swing.JPanel();
            leftPanel = new javax.swing.JPanel();
            downPanel = new javax.swing.JPanel();
            rightPanel = new javax.swing.JPanel();
            getContentPane().setLayout(new java.awt.GridLayout(2, 2));
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            upPanel.setBorder(new javax.swing.border.TitledBorder("Up"));
            upPanel.setBackground(new java.awt.Color(255, 255, 255));
            getContentPane().add(upPanel);
            leftPanel.setBorder(new javax.swing.border.TitledBorder("Left"));
            leftPanel.setBackground(new java.awt.Color(255, 255, 255));
            getContentPane().add(leftPanel);
            downPanel.setBorder(new javax.swing.border.TitledBorder("Down"));
            downPanel.setBackground(new java.awt.Color(255, 255, 255));
            getContentPane().add(downPanel);
            rightPanel.setBorder(new javax.swing.border.TitledBorder("Right"));
            rightPanel.setToolTipText("null");
            rightPanel.setBackground(new java.awt.Color(255, 255, 255));
            getContentPane().add(rightPanel);
            pack();
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            new KeyEvents().show();
        // Variables declaration - do not modify
        private javax.swing.JPanel upPanel;
        private javax.swing.JPanel leftPanel;
        private javax.swing.JPanel rightPanel;
        private javax.swing.JPanel downPanel;
        // End of variables declaration
    }

  • Multiple Key Pressing

    When I hold Tab + w space doesn't work click (I have my controls set as this for a game).
    Is there anyway to make it so i can hold those two keys and have spacebar work?
    Im on a MacBook Pro Retina 13 inch with latest version of yosemite
    Thanks for the help

    Here is an example of both multiple key press and repeat delay ignore. It is a terrible example of animation. Do not us this animation loop in a game. It will flicker far too much.import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test extends JFrame implements Runnable {
      boolean upPressed=false, downPressed=false, leftPressed=false, rightPressed=false;
      public Test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        addKeyListener(new KeyAdapter() {
          public void keyPressed(KeyEvent ke) {
         switch (ke.getKeyCode()) {
           case KeyEvent.VK_UP: upPressed = true; break;
           case KeyEvent.VK_DOWN: downPressed = true; break;
           case KeyEvent.VK_LEFT: leftPressed = true; break;
           case KeyEvent.VK_RIGHT: rightPressed = true; break;
          public void keyReleased(KeyEvent ke) {
         switch (ke.getKeyCode()) {
           case KeyEvent.VK_UP: upPressed = false; break;
           case KeyEvent.VK_DOWN: downPressed = false; break;
           case KeyEvent.VK_LEFT: leftPressed = false; break;
           case KeyEvent.VK_RIGHT: rightPressed = false; break;
        setSize(250,250);
        setVisible(true);
        Thread timer = new Thread(this);
        timer.start();
      public static void main(String[] args) {
        new Test();
      public void run() {
        while (true) {
          repaint();
          try { Thread.sleep(30);} catch (Exception e) {}
      public void paint(Graphics g) {
        g.setColor(Color.white);
        g.fillRect(0,0,getWidth(), getHeight());
        g.setColor(Color.black);
        g.drawString("Up",40,40);
        if (upPressed) g.drawString("Pressed",100,40);
        g.drawString("Down",40,60);
        if (downPressed) g.drawString("Pressed",100,60);
        g.drawString("Left",40,80);
        if (leftPressed) g.drawString("Pressed",100,80);
        g.drawString("Right",40,100);
        if (rightPressed) g.drawString("Pressed",100,100);
    }

Maybe you are looking for

  • Use ipads over local wireless network to view a webpage hosted on a mac book pro?

    My only experience of Apple products is my much loved iphone 4. I am an event  photographer currently using windows laptops  at events. My staff download my images to a powerful host laptop, select those for use and build a webpage stored in a shared

  • Automatic Clean-out orders

    Hi, I am trying to find a way to automatically generate clean-out orders in a certain resource. The restriction I have is that after 7 times I use that specific resource I have to clean it. Is there a way to insert the cleaning order or some other do

  • Using Saml token profile 1.1 with WLS 10.3

    Hi All I am a Student from IITB. I am trying use message-level authentication for webservices using SAML Token Profile 1.1 on weblogic 10.3. I have done the necessary configuration but I am getting an error "Unable to add Security Token for Identity

  • Smart mailbox acts weird

    Since Mountain Lion, Mail.app is acting quite weird. - Smart Mailbox doesn't always load on start of Mail.app, - Smart Mailbox superimposes messages over one another in the message-list, - Strange characters appear after attached ZIP files in sent me

  • Question about specification of two Tecra 8000

    I have 2 Tecra 8000 with the following specs.: Intel Mobile Pentium II 400MHz 14.1 LCD 256MB PC66 30GB HDD Intel Pentium II Xeon 300MHz 13.3 LCD 128MB PC100 30GB HDD My question is, which do you think is better of the two? If the XEON processor is be