the-via / releases

GNU General Public License v3.0
2.1k stars 225 forks source link

Not key for mac OS globe/Fn key? #92

Open LINCH8 opened 3 years ago

LINCH8 commented 3 years ago

Can someone explain how to use VIA to map key to mac layout? Nothing in the ReadMe file or anywhere I can find documents. Also, the screen brightness key that you usually can control on mac with F1, F2. How to do that on VIA? (keyboard: NK65)

Archerious commented 3 years ago

Same question here

kylecordes commented 3 years ago

So far I'm really surprised that I can't find examples of layout files suitable for use with a Mac with various size keyboards. I assumed I'd search and find a community of people sharing and comparing layout files.

I have an answer for @LINCH8 though. Look under the "special" category. You will see "screen -" and "screen +". You can map those on F1 and F2, or to a layer on the same keys.

nikosdion commented 3 years ago

Fellow macOS user with a YMD75 v3 keyboard, currently using VIA. I am not a firmware developer but I grasp enough to tell you what's going on and why — at least to the best of my understanding.

VIA runs on QMK firmware. QMK itself doesn't support the special macOS fn key for the reasons stated in https://beta.docs.qmk.fm/faqs/faq_keymap#fn-key-on-macos

While the key can, in theory, be implemented (albeit turning 6KRO to 5KRO) it also requires changing the USB vendor ID to pretend it's a genuine Apple keyboard. This may have legal implications if they included it in QMK so they just don't merge that. I am not sure it's a valid reason since I also have a Keychron K3 and a NuPhy F1 which seem to be doing exactly that: lie about the USB vendor ID. It is what it is...

My solution as a Mac user was to create a new layer which maps F1 to Scroll and F2 to Pause (i.e. F14 and F15) which macOS recognises as screen brightness up/down. I map F7 to F12 to Previous, Play, Next, Mute, Vol - and Vol + and fn+up/down/left/right to PgUp/PgDn/Home/End. This emulates most of the fn keys on an Apple keyboard. Since there is no provision for Launchpad and Mission Control (these only work on Apple keyboards because of the way Apple's Darwin kernel handles USB HID) I map fn+F3/F4 to F13 and F16. Then I went to the Keyboard preferences applet in macOS' System Options, Shortcuts tab and mapped these keys to the respective functions. In other words Launchpad, Show Launchpad is mapped to F13 and Mission Control, Show Mission Control is mapped to F16. Doing that doesn't break your Apple keyboard mappings because its special keys send special scan codes (not supported by QMK) which are recognised by macOS' kernel. I've mapped the second key to the right of my spacebar as MO(2) where 2 is the layer number with my fn+SOMETHING key mappings. I put the fn keycap there so now I get almost the same fn behaviour as an Apple keyboard. However, since the fn key is mapped at the firmware level and sends nothing over the wire I don't get double tap fn to activate dictation and single fn tap to change keyboard languages. Small price to pay for a much better typing experience :)

As to why the Launchpad, Mission Control, Globe etc keys' scancodes are not available in QMK, the reason is that QMK only has an 8-bit space for scan codes and it's mostly full. Technically it's 16-bit but the high bits are used for combined scan codes, Unicode support etc. It pretty much means that us macOS users are outta luck unless we get creative with layers and the configuration of our Macs (or use an app like Karabiner Elements to remap certain keypresses).

Now you understand why nobody makes layout files suitable for Mac for any board. The layout by itself would be half the solution. The other half is about how you configure keyboard shortcuts in macOS.

LINCH8 commented 3 years ago

So my solution was to go to "System preference" --> "keyboard" --> Check the box for "Use F1, F2, etc...." I have no solution for the globe key, but that does not bother me

dbrumley commented 1 year ago

I just got bit by this. I spent a few hours trying to figure out how to get the macos app "presentify" to work properly. Couldn't get it to work on any non-mac keyboard because it relies on the "Globe" key.

Just adding a note here in case it helps any future people looking into the same issue.

blipinsk commented 1 year ago

The partial workaround is to add a macro with:

{KC_LGUI,KC_LCTL,KC_SPC}

It's working slightly worse to the 🌐 button, but still provides the same functionality.

ygycjdr commented 1 year ago

add a macro {KC_LCTL,KC_SPC} to the Fn key using the VIA key remapping website."

steelrooter commented 1 year ago

Both the above recommended mappings weren't working for me, but this is working well:

{+KC_LCTL}{KC_SPC}{800}{-KC_LCTL}
hujunhan commented 1 year ago

add a macro {KC_LCTL,KC_SPC} to the Fn key using the VIA key remapping website."

Tested on Mac Sonoma, works for me. I use globe to change input source

danieltharp commented 1 year ago

I fought with this for a bit but VIA wasn't accepting the {+KC_LCTL} or {800} on my Keychron Q6. I wanted it on the Microphone key which was currently going to Spotlight Search. In the Keyboard Shortcuts menu on Sonoma, the setting to toggle this is Input Sources -> Select the previous input source. I just remapped it from there (which went to Cmd+Space), then remapped Spotlight to the now-free Ctrl+Space.

In practice this isn't exactly the same as the Globe button. You have to press it twice for it to register the change (which is the same most of the time), but the language picker doesn't appear long enough to be useful. If you only have two languages this is fine, and the source icon at the top will tell you where you're at.

My understanding is that the Globe key is doing some sort of M0 layer toggle under the hood that we can't replicate easily, which is why all the alternate ways of doing it feel a little different from native.

Edit to add: If you tap it three or more times with sufficient delay the language picker menu will pop up like normal.

jeremiahlee commented 4 months ago

My interim solution: In macOS Sonoma v14.5, System Settings, Keyboard, Keyboard Shortcuts, Modifier Keys, change the Caps Lock key to act as the fn Function.

QMK FAQ (accessed in July 2024) states it will not add support, pointing to a 2021 discussion.

However, that decision was before macOS Sonoma, which introduced the use of the fn/globe key as the primary key for opening the emoji picker. Before macOS 14, the fn key was used primarily to flip the role of the F keys. Apple restricted the fn+F functionality to only hardware identifying itself as Apple-made, which QMK decided against impersonating for legal reasons. The fn/globe key now has much more usefulness in macOS 14 and non-Apple-made keyboards can use the fn+ key combination for any non-F keys.

A patch for QMK was merged in Oct 2023 into the QMK develop branch, but is not merged into the master branch yet. It would be very useful for restoring the globe key behavior of opening the emoji picker and keyboard language switcher, even if it could not be used in combination with F* keys.