By Alvin Alexander. Last updated: March 8, 2018
AppleScript keystroke FAQ: Can you share an AppleScript keystroke/keyboard example?
When I created my AppleScript program to open a list of URLs in Safari I needed a way to type the URLs into Safari. That turned out to be pretty easy, I did it like this:
keystroke "http://www.apple.com/"
The much harder part was figuring out how to simulate typing the Enter (or Return) key from AppleScript. Without further ado, here's the answer:
-- simulate pressing the Enter key key code 36
I found this answer by downloading a program named Full Key Codes. It's a simple program that shows the codes for the keys as you press them on your keyboard.