Detecting keys

Hi all. Does anyone of you know how can i detect if 'Caps Lock' and/or 'Num Lock' on the keyboard are on? Once i've detected it subsequent changes will be handled by a listener but i'm stuck on how to detect if those keys are active when i first run the application.
Suggerences or a concrete answer will be appreciated.
Thanks all.

Hi,
Check out this discussion thred.
http://www.jguru.com/faq/view.jsp?EID=304596
However the code in the thread is not supported by SUN.
I hope this helps.
Regards,
Roopasri Vittal
Developer Technical Support
Sun Microsystems
http://sun.com/developers/support

Similar Messages

  • Detect key status of '*', '#' & '0' of using getKeyStates() method

    Any know the how to get key status if using getKeyStates() method of GameCanvas object in pressing keys "*", '0' & '#' (as I know, the method just can detect key pressing of number 1~9)? If no, is there any method able to do so (similar function of getKeyStates() but not keyPressed()) or how to modify the method able to function it ?

    Hello,
    Sorry for the confusion... let me try to be more clear...
    So, my test campaign for a specific UUT is composed of about a dozen sequences, which can be run independently. But I created another sequence, to work as a "batch", calling all these dozen sequences.
    Pretty much what it does is:
    1) Call first sequence in new execution
    2) Wait for execution to finish
    3) Check results of execution
    4) Add results to report
    5) Wait 10 seconds
    6) Call second sequence in new execution
    7) So on...
    So, for each new execution, I have a dedicated report, which is exaclty what I want. But for my "batch" sequence, I would like to be able to get a report saying which executions passed or failed, so I don't have to open the reports for each execution individually.
    The way I'm doing this (in step 3 above) is with the following expression:
    ( Find( RunState.PreviousStep.ResultStatus, "Passed", 0, True, False ) >= 0 ) ) ? "Passed" : "Failed"
    This way, anything different than "Passed" would give me a "Failed" result for that execution, and that's fine. The problem is that when one of the executions is terminated before it's finished, the PreviousStep.ResultStatus is giving me "Passed".
    I didn't know about the GetStates() method... Looks promissing! I'll give it a try.

  • Detect key events on anything

    If I have a JFrame with many components on it, how do I detect if a key is pressed, without having to add a listener to every component? For example, how can I check for the escape key being pressed, but not having to have componentN.addKeyListener(this); for everything?
    Thanks
    US101

    The correct way to collect the key events is the following:
    from java 1.2 to java 1.3 use the FocusManager. This class can be found in the javax.swing package. You would then need to extend the DefaultFocusManager and override specific behavior.
    for java 1.4 use the KeyBoardFocusManager. This class can be found in the java.awt package.
    Please see the following for a better explanation:
    http://java.sun.com/j2se/1.4/docs/api/java/awt/doc-files/FocusSpec.html
    Thanks for your time,
    Nate

  • How to detect key board event

    HI,
    How to detect keyboard event (Like CTRL key press shift key press) in Swing�any can any body suggest classes and interface for that�.
    Thanks

    [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to use Key Bindings

  • Detect key or modifier key when in MouseUp event of a button?

    Is there any chance to accomplish this? When I app.alert the "keystroke" or "modifiers" property, it always returns false. Any chance to detect if and probably even which (modifier) key was pressed when clicking the button?

    To detect shift, use event.shift. See the documentation for more information: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.604.html
    There's no way to know what other keys are pressed when a button is clicked.

  • Detecting key stroke

    Hi,
    I need to detect a key stroke, so I extended
    KeyAdapter and ovewrote methods. However, my program
    doen't have any windows or whatever has addlistener
    method.
    How can I do this?
    thanks in advance

    Not sure what you mean.
    When you press a key there has to be a way to detect it no matter whether you have windows or not. I can't use io because then the program just stops and waits for input.
    I have several threads running, and one of them should do something when a key is pressed.

  • Detecting Key Press at App Startup

    I would like to detect a press of the Shift key (ideally) when my application starts.
    If the user is pressing the key, display a normally hidden dialog allowing the user to select the language to use. If the key is not pressed, continue starting the application in the default language.
    From the Java Tutorial, it seems I can only detect a key press if the focus in on a GUI element is already visible. This defeats the purpose of having the special dialog be hidden.
    Any suggestions?

    From the Java Tutorial, it seems I can only detect a
    key press if the focus in on a GUI element is already
    visible. This defeats the purpose of having the
    special dialog be hidden.I believe this is because you are 'listening' for a key press from your GUI class
    Any suggestions?Sounds like you need to Listen for a key press in your running code
    you could try to give the GUI focus while still having it hidden(don't know if that would work)AND Make sure that you have your GUI and main APP in seperate threads. This would, of course, require a pause in your main app to change the language, so if you can get a key listener in your main app i think that would solve all probs.
    sorry if this sounds confusing

  • Detecting key events and setting caret position from a Document model

    Hello, I have created a "masked" JTextField that contains specific formatting (these subclasses were created prior to the advent of Sun's implementation of masked fields, and are used extensively throughout my system, so I can't easily implement Sun's version at this time)
    At any rate, here is the problem:
    Consider the following "masked" field contents (date USA format):
    The user keyboard input is:
    "10252002", which results in the text field display of "10/25/2002"
    The user presses the "delete" key in the first position of the masked field. The following result is "0/25/2002".
    This is undesirable, since all the contents of the field have shifted to the left by one position, so the first "/" is now in position 2, instead of position 3. Also, the length of the field is now 9, instead of 10.
    The field should really have the following contents: "02/52/002_", and the cursor should remain on the first position of the text field.
    I believe need for the Document model to be able to differentiate between a "back space", and a "delete", so that my overridden "remove" method in my PlainDocument subclass can handle
    insertion/repositioning of "masked literal" characters correctly, and also control the cursor movement accordingly.
    What would be the best way to handle this?

    I would re-post to the Flex Data Services forum.

  • How to detect key navigation in JTable

    Hi,
    I have a problem with JTable's events. When the user presses the mouse's left button on a cell, a mouseClicked event is generated, and my program works fine. But when the user moves from cell to cell with the cursor keys or the tab key, no mouseClicked event is generated, and my event code doesn't execute. I have seen listeners like TableColumnModelListener, but I don't want two or more events at the same time: i.e. if I go from cell 1,1 to cell 2,2, I just want one event, not one for the column and another for the row. I just want ONE event for "selection change", originated by mouse or keyboard. What should I use?
    I'm using Java 1.4.
    Thanks.

    [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to use Key Bindings

  • Detect Key Press and Mouse Motion in ONE event?

    Hi
    I am trying to create a functionality where a mouse motion from left to right performs one action, and the same motion while a given key is pressed performs another action.
    How can i combine the two events? How do I unify the KeyEvent and MouseEvent, particulary when I need to capture the directional motion of the mouse together with the key press?
    many thanks for any insight

    you cannot actualy combine them into 1 event but there is an easy way around this:boolean mouseKeyPressed = false;
    public void keyPressed (KeyEvent e)
      if (e.getKeyCode () == ??) \\ or e.isCtrlDown(), e.isAltDown(), ...
        mouseKeyPressed = true;
    public void keyReleased (KeyEvent e)
      if (e.getKeyCode () == ??) \\ or !e.isCtrlDown(), !e.isAltDown(), ...
        mouseKeyPressed = false;
    public void mouseMoved (MouseEvent e)
      if (mouseKeyPressed)
        //processAction
    }hope this helps,
    greetz,
    Stijn

  • Detecting key press on Windows

    Hi! I want to do a program that can catch every key press in Windows, no matter in wich application the user is (nope... I'm not developing a virus for those of you who are thinking that)... does any one knows how to do this?
    Thanks!

    The technique is called "keyboard hooking" and you can search for the Windows API "SetHookWindowsEx". C and Windows API knowledge is mandatory.

  • Detecting key length restrictions

    Is there an easy way to determine programatically if a user has the basic JDK 1.4 JCE implementation or has installed the unlimited strength version? Basically, I want to present a user with a means of setting the key length, but I need to know what the max is.

    Let me be a little more specific. I'm presenting the user with a GUI widget (JSlider, JTextField, whatever) that will allow them to enter the desired keysize. After they enter the keysize, they hit an 'Encrypt" button and the program goes off and does something like the following:
         int keysize = keySizeWidget.getValue()
         KeyGenerator kg = KeyGenerator.getInstance("Blowfish");
         kg.init(keysize );
         SecretKey sk = kg.generateKey();
         Cipher c = Cipher.getInstance("Blowfish");
         c.init(Cipher.ENCRYPT_MODE,sk);
    Now, if the user selects a keysize of 448, but only has the default JRE 1.4 policy files (i.e. they haven't downloaded the unlimited versions), then I get a SecurityException at the call to c.init() reporting an unsupported keysize. However, a long time passes before the exception is thrown, and the user has no feedback when they provide the keysize that the value will be rejected later when they hit the encrypt button.
    Is there any means of finding out ahead of time what keysizes a given Cipher object will accept? It would be nice to setup the interface so that they can only select valid keysizes (i.e set the maximum value of a JSlider to 128 if they don't have the unlimited encription support).
    Any help would be appreciated.

  • Any way to detect key loggers?

    I have reason to believe that a keylogger was installed on my computer over the network maliciously. How would i find it if it was installed on computer? The mac keyloggers that I looked at all run in "invisible" mode (and can be put in any folder on the computer and will work)

    What sort of network are you connected to: LAN, Corporate network, etc.?
    As for a keylogger, if you're not connected to a network that manages your Mac, there'd be no way for anyone to install anything without Admin access, and only you should have that. So unless you aren't the Admin or leave yourself logged in all the time, this shouldn't be any concern.
    If you want to look for a keylogger, you'd have to open Activity Monitor and look through all the running processes to see if there is one running. Then you could Force Quit it, and find it on your system and delete it.
    Mulder

  • Detecting external keyboard Key Down Events in Ipad2 without EditText Field.

    I am trying to detect key pressed for an external keyboard (bluetooth) in IPad2 , I was only able to do so when the focus is on EditText Field.
    Without the edit text field , the key down events are not captured by the program . Is there any work around for this issue .

    I am trying to detect key pressed for an external keyboard (bluetooth) in IPad2 , I was only able to do so when the focus is on EditText Field.
    Without the edit text field , the key down events are not captured by the program . Is there any work around for this issue .

  • Take printscreen and detect mouse/keyboard input

    hi guys,
    I'm looking a way to take printsceen and detecting mouse/keyboard input in Adobe Air app using html/ajax .. is it possible ?
    any ideas ..please

    I wrote a blog post on how to do screen capturing using Adobe AIR abnd HTML/JavaScript. Maybe it'll help you out:
    http://www.andymatthews.net/read/2009/11/05/Capture-BitmapData-with-JavaScript-AIR-applica tions
    As for detecting key input, you can add a keydown/keydown event to the document quite easily.
    document.addEventListener('keydown', function(evt){
         // do something

Maybe you are looking for

  • How to determine is a java app is running in development mode

    i am stumped with this problem. i am developeing a app in eclipse, and there is a update feature that i do not want to run when i am running the app from eclipse. now when i was developing in visual studio there was a property which i could use to de

  • IPhoto missing photos

    When I open iPhoto I have a lot of pictures that are missing, deleted by accident.  Now when in iPhoto, i receive the following message, "The volume for "Christmas 2005-12.JPG" cannot be found."  I can cancel but the next photo comes up missing and I

  • Somebody Please provide the answers for FAQs posted in Wiki

    Hi Gurus and Experienced Senior members, Thanks a lot for the support provided by all of you.You guys posted a lot of important questions on Wiki. Can somebody take the effort and provide the answers for the same so that it would be helpful to all th

  • Hundreds of "ACLs found but not expected" in DU after 10.5.8 update

    When I run Disk Utility after upgrading to 10.5.8, repair permissions shows hundreds of entries that say "ACL found but not expected.: These appear for the most part in Applications and Utilities. I have no permission errors. Is there some way to res

  • Multiple Result Sets

    Hi, I'm a new Java programmer. Right now, I'm working with databases in JSP. Is it possible to include different ResultSets within each other? For example: ResultSet set1 = stmt.executeQuery(query1); while(set1.next()) {  ResultSet set2 = stmt.execut