How do I capture two key press?

How do I captyure Ctrl+Shift+A or Ctrl+A in KeyListener?

Use the getModifiersEx() method of your KeyEvent. That contains a bitfield of the different modifiers (including CTRL and SHIFT) that were in effect when the event was generated. So you can do things like:
KeyEvent evt = ...
int keyCode = evt.getKeyCode();  // Let's say this is KeyEvent.VK_A
int modifiers = evt.getModifiersEx();
if( (modifiers & CTRL_DOWN_MASK) != 0 ) {
    // CTRL was down --> We have a CTRL-A event
}Read the KeyEvent (or rather InputEvent, KeyEvent's baseclass) API for more info.

Similar Messages

  • How can we trape the Keys Pressed on the Keyboard and do action depending on the keys

    I want to know how we can capture the keys pressed on the keyboard by the user and do necessary action depending on the key pressed by the user....
    For example.... If user press Alt+q the form should go in the Enter Query Mode.
    Can anyone tell me how i can do this in Form 6i....
    Please Help me out from this problem...
    Thanks in Advance
    Shan

    Can somebody point me to what I need to use to
    intercept all the 'keys' for an application.
    At the moment I have set Focus to parts of the
    application when the Mouse is over it, and then get
    the Keys with a KeyListener.
    Is there a way to get the keys, as long as the Java
    app is active.
    - Its an image display program, and I want to use keys
    for - next image , zooom etc etc.
    If soemone could just point me to the right part of
    the API to look in?java.awt.Toolkit.addAWTEventListener()
    then use the mask defined in AWTEvent.KEY_EVENT_MASK to listen to all the events.
    Steve

  • Detecting two keys press at one time

    i need to do a event handler, say when user press shift + enter, it will do something, else enter would do another thing
    i tried but i can't get the event handler to detect two key press, how do I go about it?

    VK_ENTER vs (VK_ENTER + SHIFT_DOWN_MASK)

  • Capture enter key press in h:inputtext

    hi,
    i have a h:inputText component in my jsf page. i need to capture the enter key pressed for this component. how can this be done.
    thanks in advance.

    You can use Javascript for this. In the onkeypress event, check if the keycode is 13 (the enter key) and handle accordingly.
    onkeypress="if (event.keyCode == 13) alert('Enter pressed!');"

  • How to get the actual key pressed in a UITextField

    Hi all , now i develop a program on iphone SDK 3.0 GM.
    I have an UITextField (created programmatically) and I have implemented the delegate as well as the UITextFieldTextDidChangeNotification so that I can react to changes in the text values.
    However, I specifically want to know when the user presses the backspace key in the UITextField when there is currently no text in the field. I can't find where I can get a specific notification of the actual key pressed, as opposed to the resulting state of the text. I'm sure there is a way to do this...help?

    I can imagine why you want to do it. I had the same problem myself and managed to circumvent it in a slightly painful way. What I did was to subclass UITextField to create a text field that always had text in it, even when it "seemed" empty. In fact the first character of the text is a space character, and then what follows is the actual text. In this way, your delegate will always get called about a backspace (when it's an attempt to delete the leading space character, obviously you should return NO in the textField: shouldChangeCharactersInRange: replacementString: method). I won't get into the details of exactly how to set everything up, like I said it is kind of elaborate and I wouldn't really recommend it unless you are desperate to have that kind of functionality.

  • Capturing Enter Key Press

    Hi
      Is there a way where we can capture the Enter Key press of the Keyboard and call an event on the Enter Key Press??
    For fields such as input field there is onEnter field where an event can be called, but we have a requirement where in we need to call an event on click of enter key, irrespective of where the focus on the page is on.
    Any inpus on this will be helpful.
    Thanks & Regards,
    Gayathri Shanbhag

    Hi Gayathri,
    See if the following link helps:
    https://cw.sdn.sap.com/cw/docs/DOC-107045
    Regards,
    Himanshu

  • KeyListener - how to handle series of key pressed

    Hi,
    Is there a way to handle a series of key pressed in the keyPressed(KeyEvent e) method. for instance, I want to popup a dialogbox when the user pressed: F9, 31, F9 ?
    thanks,
    chau

    Is there a way to handle a series of key pressed in
    the keyPressed(KeyEvent e) method. for instance, I
    want to popup a dialogbox when the user pressed: F9,
    31, F9 ?Look at the following.
    import java.awt.event.*;
    import javax.swing.*;
    /* http://forum.java.sun.com/thread.jspa?messageID=2900727 */
    /* http://forums.devshed.com/t218618/s.html */
    class KeyListenerDemo {
        public static void main(String[] args) {
            new KeyListenerDemo().go();
        void go() {
            JTextField field = new JTextField("Press a key, and watch the console.");
            field.setEditable(false);
            field.addKeyListener(new MyKeyListener());
            JFrame frame = new JFrame("KeyListener Demo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().add(field);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    class MyKeyListener extends KeyAdapter {
        public void keyTyped(KeyEvent e) {
            if (e.getKeyChar() == KeyEvent.VK_ESCAPE) System.exit(0);
            System.out.println("Typed: " + e.getKeyChar());
    }It shouldn't take too much imagination to figure out how to make the listener listen for that combination....

  • How to Run sequencially two Key-Commit triggers with different scope

    Hi all
    I have two Key-Commit triggers at form and Block level. Form level trigger is inherited from a library. In block level trigger, I have some additional checks. What I want is, to execute the Block level trigger first and than the form level. I tried working with the override/Before/after property of triggers which does the job of sequencing execution but the Raise Form_Trigger_Failure in the block level trigger doesn't stop the execution of form level trigger. Block level trigger does the checks and display corresponding alerts but than the form level trigger also executes.
    I don't wanna copy the code from Form level trigger to the block level trigger as it is common to whole application and may need some additional coding/ bug fixing later.
    Any help would be appreciated.
    RMA

    Thanks for all the help.
    In Key-Commit trigger I am just setting the Blocks' properties, nothing special, the main checks are in On-Commit trigger. I also understand the work around by using a user defined trigger but, to my knowledge, Oracle doesn't recommend it.
    My form has two datablocks, Parent and a child. The entered quantity in the Master block needs to be verified against the Number of units entered in the child block. If they are not the same, I want the alert and stop execution.
    Now I am using Pre-Insert trigger in the master block but was a little surprised because of the sequencing behavior. My understanding was that RAISE FORM_TRIGGER_FAILURE stops execution of all the code after it even is it is in another trigger/procedure ..but now it appears that I was wrong :-(
    Any suggestions??
    RMA

  • How to determine the exact key pressed when numlock disabled?

    Hi there,
    I am trying track the keyboardevent that triggered by pressing numpad keys as hotkey, but when the numlock is disabled, the same keycode, same keylocation was gotten as pressing in the standard keyboard. how can I determine if the numpad was pressed or the other control keys were pressed?
    Thank you!
    Andy

    Hi there,
    I am trying track the keyboardevent that triggered by pressing numpad keys as hotkey, but when the numlock is disabled, the same keycode, same keylocation was gotten as pressing in the standard keyboard. how can I determine if the numpad was pressed or the other control keys were pressed?
    Thank you!
    Andy

  • How do you register multiple key presses at the same time?

    Hi. I'm trying to write a first person game in OpenGL and I'm having some trouble with key listening. Right now I just use the basic AWT KeyListener. The problem that arises is that whenever I hold down a key, such as a movement key, there is a short pause after it moves me in the appropriate direction, and only after the pause does it start continuously moving me. In addition to that, I can't press multiple keys at once to get diagonal movement (I use WASD for movement). Is there something I can do with AWT to fix both of these problems, or is there something other than AWT that I should use that would be better?

    the pause is the typomatic rate of the keyboard, you can avoid that by using the keyPressed and setting a flag then a sleep(myDelayTime).... if they keyRelease--and clearing of the flag--hasn't happened after the sleep, then you're key is still down so keep firing, moving, or what ever.

  • How to detect mouse movement/key press on Mac?

    Need to write a VI that will detect/report mouse movement (ie. returns it's location) and any key (or key combinations) pressed. And, to send the mouse pointer to any location on screen. Using Labview 6i on Mac.

    The event structure is new to LabVIEW 6.1. I could post 6.1 code but I cannot save the structure for previous and LabVIEW will not open a VI from a newer version. The best place to learn about the event structure is on the What's new in LabVIEW 6.1 page.
    http://amp.ni.com/niwc/labview/lv.jsp?node=1381

  • Flash Action Script Key Press Restrictions

    Hello, so I am making a Pacman game and am using the following script for the movement of my character.
    onClipEvent (enterFrame) {
              speed = 10;
              if (Key.isDown(Key.LEFT))
                        this._x -= speed;
                        _root.char.gotoAndStop(2);
              if (Key.isDown(Key.RIGHT))
                        this._x += speed;
                        _root.char.gotoAndStop(1);
              if (Key.isDown(Key.UP))
                        this._y -= speed;
                        _root.char.gotoAndStop(3);
              if (Key.isDown(Key.DOWN))
                        this._y += speed;
                        _root.char.gotoAndStop(4);
    The problem that I'm having is that when I press the right and down keys, or any other two keys that result in diagonal movement, the character moves in that direction.  I only want the character to be able to move right, left, up and down.  The   _root.char.gotoAndStop(3); part of the script is just so that the character faces in that direction.  Is there any way to restrict the number of keys that can be pressed at once to one? Or to make it so that only the first of the two keys or the second of the two keys pressed is used? If not, is there any way to make a RIGHT and DOWN key press result in diagonal movement that also faces the character that way? Or stops the character entirely? I would throuroughly appreciate any help on the matter! Thanks in advance!
    Walt

    One way would be to incorpate "else" 's for the last three conditionals.  That would make it so that the first key determined to be down would be the key that determines the movement.
    onClipEvent (enterFrame) {
              speed = 10;
              if (Key.isDown(Key.LEFT))
                        this._x -= speed;
                        _root.char.gotoAndStop(2);
              } else  if (Key.isDown(Key.RIGHT))          {
                       this._x += speed;
                        _root.char.gotoAndStop(1);
              } else if (Key.isDown(Key.UP))          {
                        this._y -= speed;
                        _root.char.gotoAndStop(3);
              } else if (Key.isDown(Key.DOWN))           {
                        this._y += speed;
                        _root.char.gotoAndStop(4);

  • Get control after key press in listview?

    how to get control after key press in listview ????
    example
    after keyboard key PAGE_DOWN  from listview
    execute my routine ?????
    Thank' s

    PavelSafrata, your solution is right, but in my case it does not work properly, because it has to be "setOnKeyPressed", then he picks up the current line and not after the jump PAGE_DOWN.
    used the routine below, but in this case when pressed SHIFT + PAGE_DOWN, does not bring the line "new" correct.
    this.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
                @Override
                public void changed(ObservableValue<? extends Number> observableValue, Number old, Number n ) {
                    if( my_last_keyborard_registered == KeyCode.PAGE_DOWN  ) {
                        System.out.println( n.intValue() );    // when pressed SHIFT + PAGE_DOWN
                                       // get -1  << error
    Thank's

  • KeyListener does not capture Arrow key Events in textField

    Love................
    I added a key listener to TextField it does not detect
    Arrow Keys events in keyTyped, KeyPressed,KeyReleased methods
    why?????
    I want to shift focus from a textfield to other component
    on capturing Arrow key Pressed How

    Here is a Java demo where it works since it is not a printable character you must get the keyCode:
    http://java.sun.com/docs/books/tutorial/uiswing/events/example-swing/index.html#KeyEventDemo
    public class KeyEventDemo ... implements KeyListener ... {
    ...//where initialization occurs:
         typingArea = new JTextField(20);
         typingArea.addKeyListener(this);
    /** Handle the key typed event from the text field. */
    public void keyTyped(KeyEvent e) {
         displayInfo(e, "KEY TYPED: ");
    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
         displayInfo(e, "KEY PRESSED: ");
    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
         displayInfo(e, "KEY RELEASED: ");
    protected void displayInfo(KeyEvent e, String s){
         char c = e.getKeyChar();
         int keyCode = e.getKeyCode();
         int modifiers = e.getModifiers();
         tmpString = KeyEvent.getKeyModifiersText(modifiers);
         ...//display information about the KeyEvent...
    }

  • Raise Key pressed event

    Hello, any know how can I raise a key press event throw code. For example I want to simulate that the user has press the A Key. How can I do that throw code?
    Thanks a lot !!

    Hi there,
    Your question has been discussed previously in the forums. Sounds like you want to programmatically click a button in WPF.
    Please check out this post
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1329603&SiteID=1
    Thanks,
    Jennifer

Maybe you are looking for

  • Cannot use HDMI port on my Satellite P855-108

    Hi all, I have a problem with my Toshiba Satellite P855-108. When I connect the computer to a external monitor, this works perfectly with VGA but this does not work with HDMI (see error message here: [http://s4.postimg.org/5mzl8adnx/Erreur.jpg]). I t

  • How to handle audit columns using EJB and JPA.

    Hi, I am using JDev10.1.3.3 with Swing and EJB + JPA + TopLink. Every entity (POJO) has the same audit columns: @Column(name="CREATE_DATE", nullable = false) private Timestamp createDate; @Column(name="CREATE_USER_ID", nullable = false, length = 30 )

  • Why do I get this message when trying to load my home page. Multisite only works without the port number in the URL.

    When I click on the site in the address it brings up a window about page info with "General", Permission and security. Under technical details, it says "Connection not encrypted". It also says the website, odb.org does not support encryption for the

  • Creating summation in BEx for Cells

    Hello Experts, I want to display the sum of the Rows as is shown in the picture attached. Unfortunately, when I try to use the SUMCT or any other summation function in the cell, I do not get the option for selecting the ROW (for e.g. Mai or Juni or..

  • Browse other time machine disks and hidden folders

    I recently did a clean install of Snow Leopard, and used the "Browse other Time Machine disks" option to restore my documents from my backup. Now, however, I want to restore a folder that resides in the hidden /usr, and can't figure out how to do so.