Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CMT

macrumors regular
Original poster
Aug 24, 2009
104
10
Is there any way to simulate a key press in order to activate/deactivate CapsLock programmatically?

I've been searching for simulating keys but caps lock remains untouched.
 
This shows how to detect caps lock being pressed

This shows how to create a low-level key event.

I'd have though that you could combine these to do what you want…


Edit: or not. Having read the first link it may not be possible without interfacing with the keyboard driver...
 
… or not. Having read the first link it may not be possible without interfacing with the keyboard driver...

Indeed the author says at the end:

I'm looking myself for a way to programmatically toggle capslock on Mac, without success so far. But I can assure you, event taps are not the way to go.

Looks like it will not be that simple. Maybe it's time to give a try to AppleScript?

Thanks robbieduncan
 
Hmm, quite extreme. Anyway, I don't think it's an interesting idea to ask users (from my app) to install such keyboard hack…

Back to AppleScript, looks like
Code:
key code
could solve the problem (Help Library > System Events > Processes Suite > key code). The only problem is that I need to know how to use this, AppleScript is not one of my strengths.

Back to google… :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.