Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6169781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:54:56+00:00 2026-05-23T22:54:56+00:00

I would like to focus on the end of a TextField when the up

  • 0

I would like to focus on the end of a TextField when the up arrow is pressed. I’m using:

txt.setSelection(txt.text.length,txt.text.length);

This works great for any key except the up arrow. I believe that the up arrow automatically sets selection to the beginning of a TextField when it is in focus. How can I override this default behaviour?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:54:56+00:00Added an answer on May 23, 2026 at 10:54 pm

    I wanted to change the behavior of the home key, this is how I did it :
    (The following code should essentially disable the HOME key but can be modified to make it do anything)

    // Create two variables two remember the TextField's selection
    // so that it can be restored later. These varaibles correspong
    // to TextField.selectionBeginIndex and TextField.selectionEndIndex
    var overrideSelectionBeginIndex:int = -1;
    var overrideSelectionEndIndex:int;
    
    // Create a KEY_DOWN listener to intercept the event ->
    // (Assuming that you have a TextField named 'input')
    input.addEventListener(KeyboardEvent.KEY_DOWN, event_inputKeyDown, false, 0, true);
    
    function event_inputKeyDown(event:KeyboardEvent):void{
        if(event.keyCode == Keyboard.HOME){
            if(overrideSelectionBeginIndex == -1){
                stage.addEventListener(Event.RENDER, event_inputOverrideKeyDown, false, 0, true);
                stage.invalidate();
            }
    
            // At this point the variables 'overrideSelectionBeginIndex'
            // and 'overrideSelectionEndIndex' could be set to whatever
            // you want but for this example they just store the
            // input's selection before the home key changes it.
            overrideSelectionBeginIndex = input.selectionBeginIndex;
            overrideSelectionEndIndex   = input.selectionEndIndex;
        }
    }
    
    // Create a function that will be called after the key is
    // pressed to override it's behavior
    function event_inputOverrideKeyDown(event:Event):void{
        // Restore the selection
        input.setSelection(overrideSelectionBeginIndex, overrideSelectionEndIndex);
    
        // Clean up
        stage.removeEventListener(Event.RENDER, event_inputOverrideKeyDown);
        overrideSelectionBeginIndex = -1;
        overrideSelectionEndIndex   = -1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've setup a series of Filters for logcat and would like to keep focus
I would like to refresh a page after it got back into the focus.
I would like to change the text color to red when the NSTextField becomes
I have an editor with an autocomplete textfield in slickGrid. This looks (simplified) like
I already have this working in Firefox, Safari and Chrome. I would like to
This is my code: I would like to have a title in autocomplete, informing
This is my test for validation, i would like to find the best way
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
Would like a for loop in jquery so that: For every hover_link: show hidden
Would like someone to take a look at my script and tell me where

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.