BLACK FRIDAY EARLY BIRD United States Sale! Mar 23rd Only! Save 50% Sitewide!
Special Offer Buy Every Package for $8412 $149
You save $8263 (99% off)

Typing Text with Cursor in After Effects

How to create a text typewriter with a cursor in After Effects?

      1. Create a text layer.
      2. Add a Slider Control to the text layer and rename it to Text.
      3. Add a Checkbox Control to the text layer and rename it to On/Off.
      4. Alt-click on the Source Text property and paste the expression below.
    var sign = "|"; // change the blinking sign to "▌"or "_"
    var blinkInterval = 15; // edit the blinking interval in frames
    // slider with text length
    var i = effect("Text")("ADBE Slider Control-0001"); 
    // checkbox to turn the cursor on and off 
    var on = effect("On/Off")("ADBE Checkbox Control-0001"); 
    
    var frames = timeToFrames(time);
    
    var check = frames / blinkInterval;
    
    if (on == 1) {
      if (i.valueAtTime(time + thisComp.frameDuration) > i) {  
        end = sign;
      } else {
        if (Math.floor(check) % 2 == 0) { 
          end = sign;
        } else {
          end = " ";
        }
      }
    } else {
      end = " ";
    }
    
    text.sourceText.substr(0,parseInt(i)) + end;
    1. Turn on the On/Off checkbox.

    How does it work?

    Animate Text slider (a 1st keyframe must have 0 value, a 2nd keyframe – your text’s length or bigger value).

    Animate On/Off checkbox to start or stop the blinking cursor.

    Adjust blinking speed by changing the blinkInterval variable value in the expression (the lesser the value the faster is the blinking).

    You can also change the blinking sign by replacing the sign variable.

    How to erase text?

    Animate Text slider backward.

    How to make cursor to blink once the type out animation has finished?

    Animate the On/Off checkbox (a 1st keyframe will be 1, a 2nd keyframe will be 0).

    How to change the cursor’s color?

      1. Press Animate – Fill Color – RGB.
      2. Expand Range Selector 1.
      3. Alt-click on the Start property and paste an expression below.
    string = text.sourceText;
    
    counter = 1;
    for (var i = 0; i < string.length; i++) {
      if (string[i] == "\r") counter++;
    }
    
    text.animator("ADBE Text Animator")("ADBE Text Selectors")("ADBE Text Selector")("ADBE Text Index End") - counter;
    
    
      1. Alt-click on the End property and paste an expression below.
    text("ADBE Text Document").length;
    
    1. Expand Advanced property and change Units to Index

Hope you enjoyed this tutorial on how to create a type on text preset. Leave a comment if you have any questions.

 

Update. In case you need the cursor to blink at the same speed ignoring the typing use this expression instead:

var sign = "|"; // change the blinking sign to "¦"or "_"
var blinkInterval = 15; // edit the blinking interval in frames
// slider with text length
var i = effect("Text")("ADBE Slider Control-0001");
// checkbox to turn the cursor on and off
var on = effect("On/Off")("ADBE Checkbox Control-0001");

var frames = timeToFrames(time);

var check = frames / blinkInterval;

if (on == 1) {

if (Math.floor(check) % 2 == 0) {
end = sign;
} else {
end = " ";
}

} else {
end = " ";
}

text.sourceText.substr(0,parseInt(i)) + end;

 

Welcome to AEJuice Points
Become a member
With more ways to unlock exciting perks, this is your all access pass to exclusive rewards.
Already have an account? Sign in
AEJuice Points
Earn more AEJuice Points for different actions, and turn those points into awesome rewards!
Referrals
Give your friends a reward and claim your own when they make a purchase.
They get
$15 off discount
You get
$15 off discount
AEJuice Points
Share on Facebook
3 Points
Like on Facebook
1 Point
Follow on Instagram
1 Point
Place an order
3 points for every $100 spent
Celebrate a birthday
2 Points
Ways to spend
Use at checkout
1 Point = $1
Use your points at checkout with any purchase. Points will not expire.