AppleScript is a scripting language created by Apple to easily control OSX applications. It is really simple to understand but sometimes is hard to find how to do something.
If you need to execute some keyboard commands from your script you have to “tell”
System Events what keystroke simulate:
Here are some useful keystrokes: