Re: Toddler-proofing an app: selectively disabling function keys?
Re: Toddler-proofing an app: selectively disabling function keys?
- Subject: Re: Toddler-proofing an app: selectively disabling function keys?
- From: Ken Thomases <email@hidden>
- Date: Mon, 24 Sep 2012 10:16:36 -0500
On Sep 24, 2012, at 9:05 AM, Clay Heaton wrote:
> As I reported yesterday, I had luck with your second suggestion. There are a few minor problems that I would like to fix, discovered as my daughter banged on the keyboard this morning. These are the mappings on an extended keyboard:
>
> - F1, F2 - the brightness keys - I would like to disable them while my app is running so that my daughter can't turn the screen off by mistake. I can shoehorn in this approach, if necessary, to keep brightness at its original level: <http://stackoverflow.com/questions/3239749/programmatically-change-mac-display-brightness>
>
> - F4 - the Launchpad key - shows the Launchpad. Clicking an icon there launches the other app and makes it key. To me that seems like a bug with NSApplicationPresentationDisableProcessSwitching
>
> - F7, F8, F8 - iTunes keys - these control iTunes in the background while my app is full screen and key. I would like to disable these while my app is running to prevent music from playing by accident.
>
> I can intercept keystrokes on keys that aren't bound to another function, such as F5 and F6. My application doesn't even register keystrokes on the keys that are bound to other functions, however. Is there any way to capture these keystrokes and/or prevent the bound actions from occurring when they are pressed?
I agree that the Launchpad key should be disabled by NSApplicationPresentationDisableProcessSwitching. I recommend filing a bug with Apple.
I reiterate that you might try capturing the display. I know that prevents just about everything that involves another process (even the Dock, etc.) from presenting GUI. And, therefore, many of those key combinations fall through to your app.
However, it seems like your function keys are configured to behave as hardware keys. This is the default, but you can change it in the Keyboard pane of System Preferences. On the Keyboard tab, see the checkbox which reads "Use all F1, F2, etc. keys as standard function keys". When that is checked, the function keys deliver key events to your app (although the function keys can still be used in keyboard shortcuts a.k.a. hot keys, in which case your app may not see them). To access the hardware functions, like brightness, your daughter would have to hold down the "fn" key while pressing the function keys, which seems less likely.
If you don't change that preference, then there's no way that I know of to intercept those key presses.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden