ProMacTools

How to Automatically Press a Key on Mac at an Interval

Updated · by the ProMacTools team

Option 1: AppleScript

This presses Space (key code 49) every 60 seconds in whichever app is in front:

osascript -e 'repeat
  tell application "System Events" to key code 49
  delay 60
end repeat'

Terminal needs Accessibility permission (System Settings › Privacy & Security › Accessibility). Stop it with Control-C. It always types into the frontmost app, so it will interrupt you if you are working elsewhere.

Option 2: AutoKey

  1. Install AutoKey and allow Accessibility access.
  2. Pick a key (or record any key), the interval and how long to hold it.
  3. Choose a target app — for example a remote desktop window — or leave it on the focused app.
  4. Click Start. The menu bar shows when the next press happens.

In the default mode AutoKey brings the target app forward for a fraction of a second, presses the key and returns you to your app — after waiting until you stop typing.

Choosing a harmless key

If you only need to show activity, use a key that does nothing visible, such as Shift or F15. Use Space or Enter only when the app needs that exact key.

Frequently asked questions

Is there an auto key presser for Mac?

Yes. AutoKey presses any key at an interval you choose and can target a specific app. You can also script it with AppleScript and System Events.

How do I press a key every few minutes on Mac without staying in that app?

Choose the app as the target in AutoKey. It sends the key to that app and returns you to the app you were using, or sends it in the background.

Why does an auto key presser need Accessibility permission?

macOS only lets apps with Accessibility access generate key presses for other apps. It is the same permission used by keyboard tools and automation apps.