Results 1 to 5 of 5

Thread: Simulate tab key by pressing enter key

  1. #1
    Sencha User
    Join Date
    Feb 2008
    Posts
    194
    Vote Rating
    -1
      0  

    Default Simulate tab key by pressing enter key

    Is there a way to use enter key to move focus forward to next field? This should somehow behave exactly the same as tab key... I guess the easiest way would be to capture and translate enter key to tab key, but I don't know how and where.

    Thanks!

  2. #2
    Touch Premium Member pmarko's Avatar
    Join Date
    Dec 2007
    Location
    Ireland
    Posts
    58
    Vote Rating
    1
      0  

    Default

    I did it few months ago. You have to catch key codes and do your actions.

    Something from plain javascript.

    Code:
    document.onkeypress = keyPress;
    
    function keyPress(ev)
    {
    	ev || (ev = window.event);
    	var code = (ev.keyCode ? ev.keyCode: (ev.charCode ? ev.charCode: ev.which));
    	
    	// pressed ENTER or TAB
    	if (code==13 || code==9){
    	   
             .... your code here
    		return 9; // replaced ENTER key code by TAB key code
    	}
    	// pressed ESC
            else if (code==27){
    
            .... your code here
    		return false;
    	}
    	else{
    		alert (code);
    	}
    }
    Problem is with Opera browser. Opera ignore returned values from function.
    I means you can't create function for replacing characers and get it work in opera. So you have to search next field
    to be focussed yourself using script and focus it manualy by focus(),select() functions.
    I hope this will help you little bit.

  3. #3
    Sencha User
    Join Date
    Feb 2008
    Posts
    194
    Vote Rating
    -1
      0  

    Default

    Thanks for reply. Yes, I know this. I have something similar in my "old" applications.
    Just wondering if there is something like this in more "ExtJS" spirit?
    Maybe using keynav or keymap in some way.

  4. #4
    Ext User
    Join Date
    Jun 2008
    Posts
    94
    Vote Rating
    0
      0  

    Default

    to #2:

    it get key only, but did replace key

  5. #5
    Ext User
    Join Date
    Jun 2009
    Location
    Beijing China
    Posts
    82
    Vote Rating
    0
      0  

    Default

    It cannot get tab and enter key but char key.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •