jonaskohl / CapsLockIndicator

A small utility that indicates the state of the Num lock, Caps lock and Scroll lock key.
https://cli.jonaskohl.de/
Apache License 2.0
331 stars 42 forks source link

Adapt the app for Fn Key status #169

Closed Almaric78 closed 10 months ago

Almaric78 commented 10 months ago

Hello, Very Nice application !

But How to adapt it for indicate the status of Fn Key ? It would be very nice to show the status of this special Key for PCs which haven't a LED for it. Best Regards

Almaric78 commented 10 months ago

Hi, here is a page to show the importance of the Fn Key status on new Notebook/Ultraportable

https://community.frame.work/t/my-kingdom-for-an-fn-indicator/8982

jonaskohl commented 10 months ago

Duplicate of #108

Not really possible, as it's almost always implemented in the keyboard's firmware. The FN functionality is completely transparent to the OS. As far as the OS is concerned, there is no such thing as an FN key.

Almaric78 commented 10 months ago

Thanks for your response.

However I found this page which seems to say that it is possible to simulate the behavior of the Fn key with the space bar : https://geekhack.org/index.php?topic=51069.0

But it is to complicate for me, and it would run with another program which I don't know how it works : AutoHotKey

Almaric78 commented 10 months ago

Here another article that seems to say it is possible : https://www.howett.net/posts/2022-04-adding-an-ec-feature-1/ But there isn't the complete source code of the program.. 🙄😐

jonaskohl commented 10 months ago

However I found this page which seems to say that it is possible to simulate the behavior of the Fn key with the space bar : https://geekhack.org/index.php?topic=51069.0

This only simulates a function layer. All keys that are accessed on normal keyboards via the FN modifier are actually their separate key codes. For example, the "Play/Pause" media key which is accessible on my keyboard via FN + F6 actually sends the VK_MEDIA_PLAY_PAUSE virtual key code (value 0xB3). So as far as the OS is concerned, a totally different key is being pressed (Some keyboards even have those keys as separate physical buttons). This allows an application like the AHK script mentioned on this site to simulate an abitrary keypress by sending that specific virtual key code to Windows. This does not allow for checking the FN lock status as there is simpy no API for it.

Here another article that seems to say it is possible : https://www.howett.net/posts/2022-04-adding-an-ec-feature-1/ But there isn't the complete source code of the program.. 🙄😐

This seems to be specific to Framework laptops. CapsLock Indicator's goal is to be hardware-agnostic, so a vendor-specfic implementation will not be provided. Also, this is also a firmware implementation. In the article, the author modifies the keyboard's firmware to implement a FN lock feature. Again, this is completely transparent to the OS. Windows sees a keypress without FN lock enabled and with FN lock enabaled to be completely separate keys.

Almaric78 commented 10 months ago

Tranks a lot for your complete answer. 👍

Last thing, what do this script ? https://github.com/okkosh/FN-key-lock

So the last thing we can do is to simulate the behavior of the Fn keys with other keys in order to produce the same action and circumvent the primitive keyboard layout ?