Two key's Pressed at the same time

hi,
I wanna test for two buttons pressed at the same time, but it just wont happen!!
I am using this code:
public void keyPressed(KeyEvent e) {
     if (e.getKeyCode() == e.VK_X && e.getKeyCode() == e.VK_RIGHT) {
          System.out.println("Its working...");
          doWhatEver();
}is this the right code to do so, or is it completly wrong??

You can only get one key at a time, you need a boolean value for each key.
By example:
private boolean upPressed;
private boolean downPressed;
private boolean leftPressed;
private boolean rightPressed;
private class KeyAction extends KeyAdapter {
public void keyPressed(KeyEvent e) {
switch (e.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;
if (upPressed && leftPressed) {
System.out.println("North-East");
} else if (upPressed && rightPressed) {
System.out.println("North-West");
} else if (downPressed && leftPressed) {
System.out.println("South-East");
} else if (downPressed && rightPressed) {
System.out.println("South-West");
public void keyReleased(KeyEvent e) {
switch (e.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;
//Do whatever here
}

Similar Messages

  • Can iCloud on a Windows 7 PC be used with two different Apple accounts at the same time?

    Can iCloud on a Windows 7 PC support two different Apple accounts at the same time?

    You should be able to do this by using the Multifox add-on - http://br.mozdev.org/multifox/

  • Is there a way to work with two or more app at the same time on iPhone or iPad

    Is there a way to work with two or more app at the same time on iPhone or iPad?

    What i am attempting to achieve is to work with at least two app at the same time. For example: select any picture from my albums to attach them in an email. Another example is get data from an app to use it with the calc app. And there are more exaples for it. And for sure I need support for an iPad air. I mencioned the other tablet just to try to be a bit clearer.

  • How do you keep two users logged in at the same time?

    How do I keep two users logged in at the same time to be able to access home sharing?

    Fast User Switching in Users & Groups or Accounts preferences in Login Options.

  • One computer, but two user-accounts active, at the same time, in 10.6?

    I'm contemplating this setup: A current generation MacPro (running SL), with two monitors. Can I have two separate user-accounts (the Admin account and one additional user-account) active and running simultaneously from the MacPro, but, of course, displayed separately to the monitor corresponding with that user-account?
    Thank you!

    you can have two accounts logged in at the same time via fast user switching but there is no way to display them at the same time on different monitors.

  • Can I connect my Mac to two separate wireless networks at the same time?

    Need some assistance with some advanced wireless networking please....
    Upstairs I have a D-link wireless router connected to the internet and wired to a couple of PCs. Downstairs I have a minimac linked to my hifi via an airport express. I have bought a D-Link DWL-G122 usb wifi dongle.
    So I want the mini mac to connect to the airport express on one wireless network (strong signal) and to be able to connect to the internet on another network (weak signal) via the usb wifi /router.
    But the airport software and the d-link driver seem to conflict and both try to take control of the two wireless devices.
    Is there any way round this to be able to run one mac with two wireless network devices at the same time?
    Thanks

    While those with more experience may be able to correct me, I'm pretty sure that you can only connect to one wireless network at a time with your Mac Mini, unless D-Link provides their own proprietary software that bypasses the computer's Airport settings.
    Using the AirPort hardware you can only connect to a single wireless network at any given time. However in this situation the 2 attempted connections are via USB and AirPort. Therefore this requires nothing special of the AirPort drivers or settings.
    It does require that the Mac OS and applications have the capability to use either network connection (USB or AirPort) depending on what data they are trying to get. In general I understand how it is theoretically possible but I have no idea if you can configure OS X to do it.
    ...I believe one of the options when setting up the Airport Extreme Base Station is that you can extend a wireless network already in place.
    True but the D-Link is not compatible with Apple's WDS therefore this is not possible in this situation.
    If you have a newer Airport Extreme Base Station with a USB port on it...
    FYI, every AirPort Extreme base station (AEBS) has a USB port.
    BTW, birky has indicated that he/she is using an AirPort Express (AX) not an AEBS.

  • In downloading my Events from iPhoto on my Mac to my iPad Air, the Events arrive in the proper order but not showing the Key Photo.  At the same time, the Events arrive in iPhoto on the iPad in totally random order but showing the Key Photo.Why?

    In downloading my Events from iPhoto on my Mac to my Ipad Air, the Events arrive in Photos in the correct order but not showing the Key photo. At the same time, the Events arrive in iPhoto in a totally random order but with the Key phto showing. Why? of course and is there a way to shift the order in Iphoto and get a Key photo in Photos?

    HHi, thank you for the reply. I have checked my iPad and iPhone and neither has iCloud Photo Library (Beta) enabled. Turned off in both. Photostream is turned on.
    i tried to sort it out  by dragging all the photos to Events on the Mac and then deleting them from iCloud - (left hand side of iPhoto under the section 'Shared'). the photos now show up in Events. I did force quit but the issue remains. The message reads ' photos are bing imported to the library. Please wait for import to complete.'
    i can't empty iPhoto trash either. The message read "Delete error. Please wait for import to complete.'
    WHen I was moving the photos to the Events I always had a message about duplicates - to the effect that the photos already existed, did I want to import them? I clicked on Yes, import all duplicates. But when it showed the images - duplicates side by side - one showed the photo and the other was blank.
    I really don't know what to do! And I don't know how to handle my iOS devices. Is it to do with the large number of photos? Any help, advice appreciated.

  • When our iPad is in use on the internet, my iMac internet connection goes off. I can't get the two devices to work at the same time with the AirPort Express. Is there a setting somewhere I may have missed?

    When our iPad is in use on the internet, my iMac internet connection goes off. I can't get the two devices to work at the same time with the AirPort Express. Is there a setting somewhere I may have missed?

    When two or more devices conflict it typically means that the DHCP service is either misconfigured or is not running at all. DHCP provides IP addresses to local network clients.
    Is your AirPort Express base station the only router in your current network configuration? That is, is it connected directly to an Internet modem and not to another router upstream of it?

  • Can you use two duetts on logic at the same time

    can you use two duetts on logic at the same time so i can have inserts

    tracktor wrote:
    can you use two duetts on logic at the same time so i can have inserts
    Before going ahead on this you should definitely check with Apogee as I think they do not recommend using their interface(s) in an Aggregate device.
    Maybe that's changed.. not sure.
    pancenter-

  • HT203167 I downloaded two movies from itunes at the same time (both free digital copies from a dvd) and when they finished downloading... they disappeared. I've not been able to re-download them or find them.. anywhere. Any suggestions for tracking them d

    I downloaded two movies from itunes at the same time (both free digital copies from a dvd) and when they finished downloading... they disappeared. I've not been able to re-download them or find them.. anywhere. Any suggestions for tracking them down?

    If you downloaded them on your computer's iTunes then they should have gone into the Movies part of your iTunes library, if on a device (iPad, iPhone or iPod Touch) then into the Videos app - they haven't appeared there ?
    If you downloaded on your PC and they don't show in the Movies section then you could try searching for them by name (or part of their name) via windows explorer and see if that finds them. Or if you downloaded them on a device and they aren't in the Videos app then have you got a film age rating set in Settings > General > Restrictions that is hiding them, and if not can you find them via the device's spotlight search screen (swipe your first homescreen to the right) ?

  • Having two oracle clients installed at the same time

    Hi, I was wondering if there is a way to have two oracle clients installed at the same time on one computer, and if there is a way to be changing the default client between the two. I need to have installed the oracle client 10g and 8 versions on the same computer, because we have a problem with a legacy application that for some reason only works with version 8, and we need the 10g because our new applications requires 8.1 or later. We are still migrating to the new system but we developers need to have the two clients. Any help is appreciated. Thanks in advance.

    Is it possible, sure.
    Technically, clients before 8.1.5 were not multi-home compliant, so having Oracle 8 and Oracle 10g clients on the same machine is almost certainly not supported. On the other hand, I know that a number of developers at Oracle had combinations of Oracle 7 clients Oracle 8 clients, Oracle 8i clients, and Oracle 9i clients on their development machines at the same, so you shouldn't have too many major issues.
    Most "default client" issues come down to which ORACLE_HOME is first in the system's PATH. Ideally, you would leave the Oracle 8 ORACLE_HOME first in the path and explicitly reference the 10g ORACLE_HOME when configuring anything that relies on the 10g client.
    Justin

  • Can two subVI show up at the same time?

    Can two subVI show up at the same time?

    Hi,
    Save the vi as a template (*.vit), then you can open it (dynamically) as
    often as you want. If you make the vi "floating", you get the best results.
    Regards,
    Wiebe.
    "smal" wrote in message
    news:[email protected]..
    > Hi,
    > What if the subvi has to be called dynamically (hence using call by
    > refrence node).
    > In fact I want to run a subvi each time a button is clicked
    > independent of the others(it gets just some parameters from the caller
    > vi & must continue running so the user can interact with it via its
    > front panel )
    >
    > Thanks for your attention in advance.

  • Two Calendar Windows open at the same time?

    I would like to have two calendar windows open at the same time (with different months shown). Is this possible?

    Nancy,
    That is not possible with the current version of iCal.
    If you find a need for that feature, I would invite you to Provide iCal Feedback.
    ;~)

  • When two Computers are online at the same time, constantly losing internet connection

    I recently added a WRT160N router to my PC for a wireless Laptop elswhere in the house as well as adding a new network adapter card to my PC. When both the Laptop and the PC are online at the same time I am constantly getting booted offline and having to reset the connection, but when just the PC is on there are no prbloems and everything seems to work fine.
    Any suggestions would be helpful, thanks in advance
    Andy

    In this case i think you need to change some settings on your Router. Follow the steps below.
    Open an Internet Explorer browser page on your wired computer(desktop).In the address bar type - 192.168.1.1 and press Enter...Leave username blank & in password use admin in lower case...
    For Wireless Settings, please do the following : -
    Click on the Wireless tab
    - Here select manual configuration...Wireless Network mode should be mixed...
    - Provide a unique name in the Wireless Network Name (SSID) box in order to differentiate your network from your neighbours network...
    - Set the Radio Band to Standard-20MHz and change the Standard channel to 11-2.462GHz...Wireless SSID broadcast should be Enabled and then click on Save Settings...
    Please make a note of Wireless Network Name (SSID) as this is the Network Identifier...
    For Wireless Security : -
    Click on the Sub tab under Wireless > Wireless Security...
    Change the Wireless security mode to WEP, Encryption should be 64 bit.Leave the passphrase blank, don't type in anything...Under WEP Key 1 type in any 10 numbers please(numbers only and no letters eg: your 10 digit phone number) and click on save settings...
    Please make a note of WEP Key 1 as this is the Security Key for the Wireless Network...
    Click on Advanced Wireless Settings
    Change the Beacon Interval to 75 >>Change the Fragmentation Threshold to 2304, Change the RTS Threshold to 2304 >>Click on "Save Settings"...
    Now see if you can locate your Wireless Network and attempt to connect...

  • Two macs running garageband at the same time

    Hi. I am using GarageBand on two Mac's at the same time and would like to know how I can record both parts of the tracks, I guess I'll have to use an external recording device of some sort but I do not know which or how I would set this up. Basically, I am playing a part of the song on one Mac and the other part on the other Mac and would like the two Mac's to be liked up to a seperate recording system so I can record the mix, hopw someone can help, thanks.

    The biggest problem you are going to have is sync. There is no way to keep these two computers in sync unless you hook up some kind of KVM USB splitter for your keyboard. Both machines would need to be identical in setup or this will not work. Playback and record buttons need to be pressed at the exact same time. The mouse can be used to trigger events (such as record enable) to each computer. It is not a very elegant or pragmatic way of gaining more tracks.
    The better way is to use a dual G5 with a big monitor.

Maybe you are looking for