Intercept tab key press

Hi,
For my application I need to use a textarea as a code editor
but my problem is that tabulation key is used to give the focus to
the next control but I want the tab key to simply insert a
tabulation.
Here is my current state:
I have this in my textarea definition:
keyDown="onKeyDown(event)"
and in a script block:
private function onKeyDown(event:KeyboardEvent):void
if( event.keyCode == Keyboard.TAB ){
ta.text+= "\t";
When I hit the tab key a tabulation is added as planned but
the focus go to the next control, I tried "event.preventDefault()"
and "event.stopPropagation()" but both failed, the focus still
manage to leaves the control. I also tried to change all my
controls focusEnabled properties to false but now the problem is
that the event is not event fired when pressing tab, it is fired
however when I press alt+tab...
I hope someone has a magical solution since I have no ideas
left :/

Hi arjunravinarayan!
Thanks for anwer!
The question is that I want no change in the TextArea content.
When a press the tab key, a tab space is added to TextArea.
Sergio Martin

Similar Messages

  • Why i am unable to catch the 'TAB' key press?

    hi
    i have an application where i have 2 text fields and one button in order say t1, t2 and b1.
    on tabbing t1 cursor moves to t2 and on tabbing t2 cursor moves to b1 and on tabbing b1 cursor moves to t1.
    now when i press tab button on any of the component i have written a keyListener for that to catch 'TAB' key using the comparision
    if( e.getKeyCode() == KeyEvent.VK_TAB )
    but its not catching the tab key pressed on any of these 3 components....
    why like this...
    i want to catch the press of 'TAB' key and write some action for it... but unable to catch the 'TAB' key press.
    anyone could help me in this....
    thanx in advance,
    -Soni

    I seem to remember this question being asked before. I think the answer was that the FocusManager intercepts the TAB key. I don't remember the solution but you can try searching the forum.

  • Disable Alt+F4, Alt+Tab key press

    Hi Guys, my WPF launched with maximized mode & i must restrict the users for the items:
    'Alt + F4': Not to use 'Alt + F4' to close the application
    'Alt + Tab': Not to switch to another application in the system, so i want to disable 'Alt + tab' key-press.
    Note: I couldn't find any solution specifically for 'Alt + tab' key-press.
    Thank you

    Disabling ALT + F4 can be done by adding an event handler for the window's KeyDown event:
    public Window1()
    InitializeComponent();
    this.KeyDown += Window1_KeyDown;
    void Window1_KeyDown(object sender, KeyEventArgs e)
    if (e.Key == Key.System && e.SystemKey == Key.F4)
    e.Handled = true;
    >>I couldn't find any solution specifically for 'Alt + tab' key-press.
    The ALT + Tab keyboard stroke is handled at system level so you will need to hook into the Windows API to get access to the keyboard and intercept these calls somehow. Please refer to my example of how to use a low-level keyboard hook in WPF in the following
    thread for more information:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/cbb5d6ea-432d-42b5-a6e1-814cda9db030/registerhotkey-for-capslock-doesnt-work-in-laptops-keyboard?forum=wpf. There is probably no easy (or easier) way of doing this.
    Here is an article that may also be helpful for you:
    http://www.codeproject.com/Articles/14485/Low-level-Windows-API-hooks-from-C-to-stop-unwante
    Hope that helps.
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

  • Unable to receive Tab key press event

    Hello,
    I have written a component which extends JComponent.
    For that , when Tab key is pressed I need to process something.
    I have overridden the function processKeyBinding in my class.
    But I am not getting any event for tab key press. For all the other key press events, the function is being called.
    I also tried to create a action and add it to the action map. But that is also not working.
    Can anyone explain me why it is not working and give me the solution.
    Thanks in advance,
    Anu

    public static void removeTabFromFocusTraverval(Component c) {
         int id = KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS;
         Set strokes = c.getFocusTraversalKeys(id);
         Set newStrokes = new HashSet(strokes);
         newStrokes.remove(KeyStroke.getKeyStroke("TAB"));
         c.setFocusTraversalKeys(id, newStrokes);
    }

  • To trigger event or action on "TAB" key press on web dynpro view

    Hi, I need to trigger event on "TAB" key press on web dynpro view , is it possible?How?

    Hi Dipak
    What Madhu said is correct. Tab key is pre-configured to move cursor from 1 field to next field. we can not create an event on tab key press.
    Regards
    Gaurav

  • Make Tab Key Press Event

    Hi You all,
    I'm trying to make an automatic Tab Key Press after fill some data to oEditText  , plz guide me how can i do that ?
    I will appreciate your help.
    Peter.
    Edited by: PeterHoang on Oct 12, 2011 12:22 PM

    Hi
    You can use sendkeys method for this
    SBO_APPLN.SendKeys("{TAB}")
    Regards
    Arun

  • Anulate tab key press

    Hi all!
    I have a little problem.
    How can I anulate a tab key press in a TextArea?
    I have this TextArea in an Applet and it's ocurrs only with Microsoft VM. I try with consume() method of KeyEvent but no work.
    Thanks a lot.
    Sergio Mart�n

    Hi arjunravinarayan!
    Thanks for anwer!
    The question is that I want no change in the TextArea content.
    When a press the tab key, a tab space is added to TextArea.
    Sergio Martin

  • PJC tab-key navigation problem within bean  (FORMS intercepting tab key??)

    Using Forms 10.1.2.3, IE7, JRE 1.6
    When attempting to navigate within the bean area, it appears as if FORMS is suppressing the keyEvent when the tab key is pressed. This means that I cannot use tab or shift-tab to navigate within the PJC's editable fields/buttons. I can click on them, enter data within them, but tab is somehow intercepted. When I place my PJC within a normal (non-forms) Java window, everything works fine.
    Documentation that I've read seems to indicate that tab should navigate perfectly fine within the bean area.
    Any ideas?

    Hi,
    This is how I did it. Sorry about the formatting, it was OK when I pasted the code fragment in.
    My class contains this in the variable definitions.
    private AWTEventListener keyListener = new DoKey ();
    private class DoKey implements AWTEventListener {
    public void eventDispatched (AWTEvent e) {
    //System.err.println("eventDispatched " + e.toString());
    //System.err.println("eventDispatched source " + e.getSource().toString());
    if ((e instanceof KeyEvent) && (e.getSource() instanceof Component)) {
    * The event was a key pressed event and it was sourced from a Component.
    KeyEvent evt = (KeyEvent) e;
    if (evt.getID() == evt.KEY_PRESSED) {
    if (evt.getKeyCode() == evt.VK_TAB) {
    if (evt.isShiftDown()) {
    ((Component)e.getSource()).transferFocusBackward();
    else {
    ((Component)e.getSource()).transferFocus();
    The listener is enabled when on initialisation
    Toolkit.getDefaultToolkit().addAWTEventListener (keyListener, AWTEvent.KEY_EVENT_MASK);
    Regards, Tony C

  • The correct approach to intercept TAB key

    Dear Experts,
    I have developed a GUI out of javax.swing. The GUI consists of JFrame, several JPanels and javax components, such as JTextField, JLabel, JComboBox, JTable and many more.
    Now, I want to change the behavior when user presses TAB key. By default TAB key moves focus from a component to another component. How can I disable this?
    I come to two alternatives that I am not sure which one is the correct approach. Could you please advise me?
    Alternative 1.
    Use key binding on GlassPane.
    Alternative 2.
    Use event-handling on GlassPane.
    If those alternatives are not the best one, could you please provide another alternative?
    I have tried the following, but they didn't work...
    Action doNothing = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Tab-key is pressed.");
    cmbPCode.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "doNothing");
    cmbPCode.getActionMap().put("doNothing", doNothing);or
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "doNothing");
    getRootPane().getActionMap().put("doNothing", doNothing);where cmbPCode is a JComboBox that receives focus when the GUI shows up.
    Thanks for your help,
    Patrick
    Edited by: Patrick_Stiady on Mar 31, 2009 6:51 AM

    Thank you for the advice. I am developing an application where the user is not computer literated, so that I have to limit functional key as many as possible and only allow several keys to be active. For example, I don't want TAB key to change the focus, instead I want TAB key to do nothing.
    I have tried keybinding, because I think this is the most relevant, but somehow I failed to recognize which component should be bound with keybinding. I have tried to change the input map of the component that receives the focus when the GUI is displayed (cmbPCode) as can be seen on my first post. I also tried to change the input map of the root pane. Both are not successful.
    Now, I wonder whether
    1. it does not work because the key is not consume()?
    2. Or should I use key listener, which I would only use if keybinding were unable to serve my goal?
    3. Or should I learn how to intercept key on the glass pane?
    4. Is keybinding able to nullify default action, such as changing focus by TAB key? I am asking this, because I'm going to nullify other important key such as ENTER key.
    Thank you for any guidance,
    Patrick

  • How to show list of items when the user pressed tab key in an empty field

    Hi all
    i would like to know if there is a way to open a form with items list which will be shown to the user when he pressed the tab key within a field for instance "item code" field will present a search form with a table filled with item codes and their description.
    i'm currently working in 2004 version. i know how to catch the event.
    i'm creating a form with a matrix object binded to a datasource which is connected to the data base table which contains all the items.
    what would like to know if there is a better way to this. maybe using buisness partner objects. and if so how
    appriciate the help
    Yoav

    You Should use Formatted Search in this case.
    You must create and associate a query for your field.
    click on the field you want items to be listed and press Shift + F2
    catch the keydown event of this field  and check pval.charpressed = 9 (tab key press)
    then execute
    SBO_Application.SendKeys("+")

  • How to set current row in table after use tab key on inputText

    Hello all,
    My first post .., I'm newbie in ADF and I will try to explain my problem.
    For the moment we use ADF 11g (11.1.1.4), in a jsff page I have a table with an inputText column.
    On the valueChangeListener of the inputText, I invoke a method in a viewScope bean which call an EJB method, make some services in the EJB on the line modified. After that I refresh the VO and the table (because others values on the line have been modified) and reset the focus on the same inputText modified by the user with javaScript because focus was lost after refresh.
    So far, everything works fine.
    When I use the arrow keys to change the selected row in the table, it's work fine (focus is still in the next or previous inputText), but if user try to use tab key to change the current line, the inputText on the next line have the focus but the current row of the table is not changed (I think it's normal).
    My question : how can I change the current row after tab key pressed in this case ?
    I don't know if it's really clear, not easy to explain, don't hesitate to ask more details.
    Thanks in advance.

    Frank Nimphius wrote:
    Hi,
    My question : how can I change the current row after tab key pressed in this case ?
    Use a client event to listen for the keyboard entry and intercept the tab. The use af:serverListener to call the server to set the rowKey on the table and issue a PPR for the table to re-paint
    See sample 11 on http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#CodeCornerSamples
    to learn about how to use the client listener and server listener
    FrankHi,
    Thanks a lot for your advices, I used the client and server listener
    I used this code on the method call in order to change the selection after key tab pressed, I don't know if it can be easier, but it works.
              if (LOGGER.isDebugEnabled()) {
              LOGGER.debug("START changeSelectedRow");
              RowKeySet oldRowKeySet = myTable.getSelectedRowKeys(); // get oldRowKeySet
              if (oldRowKeySet == null) {
                   if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("oldRowKeySet is null");
                   return;
              RowKeySetImpl newRowKeySet = new RowKeySetImpl(); // The new RowKeySet use to change the selectedRow
              DCIteratorBinding bindingIterator = ADFUtils.findIterator(MY_ITERATOR);
              bindingIterator.setRangeSize(-1);
              // set the new index of the current row.
              int index = bindingIterator.getCurrentRowIndexInRange();
              if (index < bindingIterator.getAllRowsInRange().length - 1) {
                   index++;
              bindingIterator.setCurrentRowIndexInRange(index);
              // get the current row after changed the index
              Row currentRow = bindingIterator.getCurrentRow();
              if (currentRow != null) {
                   ArrayList nextLst = new ArrayList(1);
                   nextLst.add(currentRow.getKey());
                   newRowKeySet.add(nextLst);
                   // set the new selectedRow
                   myTable.setSelectedRowKeys(newRowKeySet);
                   SelectionEvent selectionEvent = new SelectionEvent(oldRowKeySet, newRowKeySet, myTable);
                   selectionEvent.queue();
                   AdfFacesContext.getCurrentInstance().addPartialTarget(myTable);
              if (LOGGER.isDebugEnabled()) {
                   LOGGER.debug("END changeSelectedRow");
    Best Regards
    Benjamin

  • JTable tab key navigation with JComboBox Cell Editors in Java 1.3 & 1.4

    Hello - this is one for the experts!
    I have a JTable which has an editable JComboBox as one of the cell editors for a particular column. Users must be able to navigate through the table using the tab key. After editing a cell a single tab should advance the cell selection to the next column and then the user should just be able to start typing to populate the cell.
    However, i've come across some really frustrating differences between the Swing implementation of JDK1.3.1_09 and JDK 1.4.2_04 which means this behaviour is very different between versions!....
    1. Editing Cells and then advancing to the next column using tab.
    Using standard cell editors (based around JTextFields) in 1.3.1 the user has to press tab twice to traverse to the next column after editing. However, in 1.4.2 a single tab key is enough to move to the next column after editing.
    2. Editable JComboBox editors and and advancing to the next column using tab.
    Using JDK 1.3.1, having entered some text in the editable combo it takes 2 tabs to transfer the selected cell to the next column. With 1.4.2 a single tab while editing the editable combo ends editing and transfers the selection out of the table completely?!?
    With these 2 issues I don't know how to make a single tab key reliably transfer to the next cell, between java versions. Can anyone please help me?!??!
    (i've attached test code below which can be run in both 1.3 and 1.4 and demonstrates the above behaviour.)
    package com.test;
    import java.awt.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class TableTest4 extends JFrame {
         private JTable table;
         private DefaultTableModel tableModel;
         public TableTest4() {
              initFrame();
          * Initialises the test frame.
         public void initFrame() {
              // initialise table
              table = new JTable(10, 5);
              tableModel = (DefaultTableModel) table.getModel();
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              table.setRowHeight(22);
              JScrollPane scrollPane = new JScrollPane(table);
              getContentPane().add(scrollPane);
              JButton dummyBtn1 = new JButton("Dummy Button 1");
              JButton dummyBtn2 = new JButton("Dummy Button 2");
              // initialise frame
              JPanel btnPanel = new JPanel(new GridLayout(2, 1));
              btnPanel.add(dummyBtn1);
              btnPanel.add(dummyBtn2);
              getContentPane().add(btnPanel, BorderLayout.SOUTH);
              // set renderer of first table column to be an editable combobox
              JComboBox editableCombo = new JComboBox();
              editableCombo.setEditable(true);
              TableColumn firstColumn = table.getColumnModel().getColumn(0);
              firstColumn.setCellEditor(new DefaultCellEditor(editableCombo));
         public static void main(String[] args) {
              TableTest4 frame = new TableTest4();
              frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
              frame.pack();
              frame.setVisible(true);

    Run the above code in 1.3 and 1.4 and you can see that after editing a cell, the tab key behaviour works differently between versions.
    I don't believe by adding a key listener to the cell editors will have the desired effect.
    I've read other posts and from what i've read it looks like the processKeyBinding method of the JTable can be overridden to manually handle key events.
    Has anyone done this to handle tab key presses so that the same java app running under 1.3 and 1.4 works in the same way ??? I would really appreciate some advice on this as its very frustrating !

  • ActiveX is stealing my key presses?

    Hi all,
    I have a fairly simple front panel with a handful of LabVIEW controls and an ActiveX container. In the ActiveX container is the Adobe Reader plugin.
    My vi works, but exhibits an odd behaviour that I presume is focus related. Once the ActiveX control is programmatically told to open and display a pdf file, it seems to steal the focus - permanently. If I select my LV string control, I can select any text in it, but key presses are all still sent to the Adobe Reader ActiveX control. If I click a few check boxes, then the string control again, it still doesn't accept my keyboard presses. The only way I've found to stop all this is to press tab, as this causes LabVIEW to move the focus away to the next control in the tab sequence. After that, all is ok until the next pdf file is read into the ActiveX control, and then I'm back at square one.
    Now I don't want to be telling my customers, "that's alright mate, just make sure you press the tab key after every pdf you generate and you'll be just fine."
    I've tried programmatically moving the focus away from the ActiveX control, and setting "SkipTabbing" to true, but this doesn't work.
    Anyone know how I can prevent this darned ActiveX control from permanently stealing my focus?
    Thoric (CLA, CLED, CTD and LabVIEW Champion)
    Solved!
    Go to Solution.

    nathand wrote:
    Unfortunately I don't have a good solution, but I can sympathize - I've had the same problem.
    Hi nathand, thanks for the sympathy 
    I've tried a few things, including navigating away from and straight back to the tab panel which houses the control to attempt to change the control focus. I've even tried simulating the keyboard TAB key press, which actually works - but only once for some annoyingly unfathomable reason! A second call to the ActiveX AdobeReader control makes it the focus again, but this time permanently. I've even tried putting the ActiveX control into a subvi that's hosted within a subpanel - no difference.
    Ultimately, like yourself, I've had to settle for a separate window, which I've called a Preview Window. Of course, putting my large ActiveX container in a separate subvi has left a dirty big empty space on my main vi front panel 
    I'm tempted to try to hide all borders around the preview window, and programmatically control its location such that it sits perfectly over the empty space within my main front panel. Of course, this means monitoring main panel window resizes and movements to maintain the correct relative locations, but it's do-able...
    I've got a new problem now - I thought about using Invoke to Get the Front Panel Image, then place this into a picture control. However, it seems the AdobeReaderActiveX control evades the LabVIEW Front Panel Image method, revealing nothing but the blank front panel colour behind the container. I can't seem to find a way around this either!
    Dam dam dam dam dam dam dam dam dam dam dam dam!!!
    Thoric (CLA, CLED, CTD and LabVIEW Champion)

  • Disable tab key

    Hi all!
    I have a little problem.
    How can I anulate a tab key press in a TextArea?
    I have this TextArea in an Applet and it's ocurrs only with Microsoft VM. I try with consume() method of KeyEvent but no work.
    Thanks a lot.
    Sergio Martin

    Hi atmguy.
    Thanks for anwer!
    I don't want tab spaces in the TextArea when I press the tab key.
    When I run my applet in Microsoft VM, the tab key is catch in
    KeyEvent.KEY_RELEASED time:
    if (e.getID () == KeyEvent.KEY_RELEASED)
    int keycode = e.getKeyCode ();
    if (keycode == KeyEvent.VK_TAB)
    e.consume ();
    transferFocus ();
    I hope I have explaint myself well enough.
    Thanks

  • Pressing tab key within table not scrolling to next input field

    Hi All,
    I have a table with editable and read only fields. I have more than 20 columns. When the tab Key is pressed it scrolls only to the editable fields that are in the visible screen. It does not scroll the table to the right to the next input field.
    However if I change the screen size so that the scroll bar is required for the browser then it will scroll across moving the browser scroll bar, moving the cursor to the input field that was not visible. Again it does not go further moving the scroll bar within the table to the next editable field to the right.
    The table has been set to scrollable with the scrollable column count set to 8.
    We are using explorer 8 on 7.01
    Is it possible to have the tab key move from input field to input field scrolling the table to the next input field if it is not visible yet?
    Thanks
    Bruce

    What you describe sounds like the correct functionality.  If you set a scrollable column count, only the visble rows are actually rendered on the client side.  When you use the horizontal scroll bar, you are triggering a server side event to retrive the next set of visible columns.  Therefore the browser doesn't actually know anything about non-visible columns and hence the tab can't go to them.
    When you increase the number of visible columns (or don't set anything for visible column) you render al the columns on the client side and use the browser scrolling.  Therefore the tab works.

Maybe you are looking for

  • My music from itunes doesn't play on my new iPhone

    i have recently upgraded my iPhone from the 4 to the 4s, i have transferred everything from my old phone to my new one without any problems but when i go to play some music which i bought off iTunes it is not playing, and if it is an album it will sk

  • Software update error while connecting to internet

    Hi I have a problem with my 3 computer (all mac) They cannot get sofware update while connecting to the server... it worked last week and now it don't on 3 computer!! It seem that they have a problem on the apple server maybe?... That's the message :

  • Problem with opening files

    Okay so I've had a look around and can't see any other discussions about this problem, Basically I started a new job on Monday and as part of that I had to set up my laptop which is a 2009 Macbook Pro with Mavericks. The problem is that when ever I g

  • List Import Launching Problem

    Hi, When SADMIN launches import, all works fine; but when non SADMIN user tries to launch list import, the "+You cannot currently update this record. Please check the No Update properties on the Applet, Business Component, and Link.(SBL-DAT-00284)+"

  • Convert Integer to binary

    I want to co convert an interger in binary code. For example int 1= 001010101010101. Is there a method to convert this?