You can't catch when fn
key was pressed.
However if you press fn+F7
it would generate different event
object than if you press solely F7
- considering that there is function bound to that key. So in my case I do not have anything bound on F7, therefore there will be no event generated if I press fn+F7
keys.
If I press F3
and then fn+F3
, following codes will be generated:
KeyboardEvent {isTrusted: true, key: "F3", code: "F3", location: 0, ctrlKey: false, …}
KeyboardEvent {isTrusted: true, key: "AudioVolumeUp", code: "AudioVolumeUp", location: 0, ctrlKey: false, …}
Hope this helps.
----More info below----
As I expected fn
key does not really generate any keycode. Instead, on the hardware level, when pressed in combination with some other keys it is generating unique keycode.
Information based on answer from this question: https://askubuntu.com/questions/827925/remapping-the-fn-key
And this:
https://askubuntu.com/questions/270416/how-do-fn-keys-work