AppleScript and System Events "keystroke" function lead to incorrect casing when using uppercase letters

Number:rdar://29182929 Date Originated:09 Nov 2016
Status:Closed Resolved:Yes
Product:macOS Product Version:macOS Sierra 10.12.2 Beta (16C41b)
Classification:Serious Bug Reproducible:Always
When using the "keystroke" function of System Events using AppleScript or from Objective-C with the ScriptingBridge framework, lowercase letters followed after an uppercase letter or symbol that requires the press of the shift key modifier appear as uppercase or mixed case.

This happens even though no modifier keys are pressed on the keyboard while executing the script. In fact no keys are pressed on the hardware keyboard at all.

Also, the actual output is different each time.

I've attached a sample script that illustrates the problem and a short video recording of my screen when the issue happens.

Steps to Reproduce:
1. Open Script Editor
2. Either open the attached sample script or paste this:
tell application "Terminal"
	tell application "System Events" to keystroke "This is a test"
end tell
3. Watch the output in

Expected Results:
The script should properly print each entered character in the correct casing.

Actual Results:
The casing is different from what was entered and differs with each run.

macOS Sierra 10.12.2 Beta (16C41b)


Approximately every 10 runs the output is actually correct.

'Keystroke Test.scpt' and 'SystemEvents_Keystroke_Bug.mp4' were successfully uploaded.


Apple Developer Relations

We believe this issue is resolved in the latest macOS 10.12.4 beta.

Please test with the latest macOS beta. If you still have issues, please update your bug report with any relevant logs or information that could help us investigate.

Felix Deimel

Confirmed to be resolved in 10.12.4 beta 1 on a MacBook Pro 13" Late 2016 and a MacBook 12" Early 2016.

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!