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;

 

-50%
-50%
00hrs : 00mins : 00sec
Happy HolidaysSale sitewide
Shop now

Get 5% off when you sign up

By subscribing you agree to your email being stored and used to receive the emails in accordance to our Privacy Policy
descount