Recent

Author Topic: OSX FUnction Keys  (Read 2666 times)

Josh

  • Hero Member
  • *****
  • Posts: 1271
OSX FUnction Keys
« on: September 26, 2016, 05:05:53 pm »
Hi
I have been trying to detect when the Function keys are presssed on OSX, but it will not detect.
It is working fine on Windows PC; but on OSX it is athough the build in shortcuts ( ie Brightness, calculator etc) are taking precedence.
Is there a way to intercept the keypresses.
ie VK_F1

Hope that makes sense
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: OSX FUnction Keys
« Reply #1 on: September 26, 2016, 05:17:12 pm »
You have to press the "Fn" key at the same time as the function key to send the function key to an application. You can make this the default (for all applications) in the Keyboard system preferences (in which case you have to press "Fn" with the function keys to get the original behaviour).

It is possible for an application to change the default behaviour of the function keys only when that application is active, but it requires the use of the OS X/macOS accessibility APIs (I don't know which ones exactly), and then the user still has to explicitly grant your application permission to use the Accessibility APIs via the Accessibility System Preference (because they can also be used for nefarious purposes).

Josh

  • Hero Member
  • *****
  • Posts: 1271
Re: OSX FUnction Keys
« Reply #2 on: September 27, 2016, 03:40:21 pm »
Hi Jonas,

Thanks for your fast response; and clarification of using the Fn Key combo to get the Function key detection; what is still odd is that on 2 test machines the F1 key is not being detected at all; the F1 key is operational in other application; yet it does not fire in my application; (using Fn+F1) all other seems to be fine.
I will experiment and see if some other keycode is being triggered; the 2 machines that are not detected are using non US keyboard layout; whether that has something to do with it?
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

 

TinyPortal © 2005-2018