# Automatically move focus to next text box

**URL:** https://forum.kirupa.com/t/automatically-move-focus-to-next-text-box/184639
**Category:** flash
**Created:** [April 6, 2006, 2:36pm UTC](https://forum.kirupa.com/t/automatically-move-focus-to-next-text-box/184639 "2006-04-06T14:36:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![hectors](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hectors/32/2118_2.png) [@hectors](https://forum.kirupa.com/u/hectors)
#### Post date: [April 6, 2006, 2:36pm UTC](https://forum.kirupa.com/t/automatically-move-focus-to-next-text-box/184639/1 "2006-04-06T14:36:09Z")

</div>

Hi there, I’m trying to move the focus between text boxes, when I get to the end of one text box I would like the cursor to jump to the next one and also if the user presses delete when the cursor is at the start of the text box I would like the cursor to move to the end of the previous line. I have set maximum chars per line:  
[INDENT]var maxCharsPerLine:Number = 10;  
if (lineOne\_txt.length == maxCharsPerLine) {  
trace(“chars recahed”);  
}[/INDENT]  
and then a bunch of else if statements to move the focus around e.g.  
[INDENT]if (lineThree\_txt.text == “” && Key.isDown(Key.BACKSPACE) && lineTwo\_txt.text.length\>=1) {  
Selection.setFocus(“lineTwo\_txt”);  
}[/INDENT]

but this seems to be a bit complicated for quite a simple thing, also when the focus goes back to the previous line (after pressing delete) all characters in that line are removed.

I am sure I am trying to do something very simple in a very convoluted way, could some one show me the wood for the trees please?

thanks in advance

hectors
