How to translate these commands into AppleScript
First of all, be careful with this kind of thing. System automation utilizing something like a virtual keyboard like this can lead to unfortunate side-effects if you end up sending key strokes to an unintended target.

However, here:

repeat
    tell application "TextEdit"
        activate
        tell application "System Events" to key code 124
        delay 2
        tell application "System Events" to keystroke "l"
        delay 2
        tell application "System Events" to keystroke "c"
        delay 2
        tell application "System Events" to keystroke "cool!"
        delay 2
        tell application "System Events" to keystroke return
        delay 2
        tell application "System Events" to key code 53
        delay 2
    end tell
end repeat


Let's go through this code:

First, we are doing a simple repeat without end. This is not a good idea, but you asked for it and that's what you get. If you wanted just a finite number of times, you could add # times after repeat. Ex: repeat 3 times. There are many other methodologies to repeat beyond this answer.

Then you are going to create a tell block and activate the application you are sending these commands to. If you do not do this, you will be sending keystrokes willy nilly to whatever happens to be the active application at the time.

You will then do a series of having the "System Events" application emulate a keystroke and delaying for a count. delay accepts decimals as well as integers for number of seconds. Note that for the Right Arrow and Escape I used key code 124 and key code 53 respectively. The list of key codes can be found in various locations online with a Google search for 'applescript key codes'. Here is a current one at the time this answer was written: http://eastmanreference.com/complete-list-of-applescript-key-codes/

Finally, you will end the tell block, no longer sending AppleScript to "TextEdit" and then you will end your repeat block.