cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

TIS API is deprecated #173

Open mkrueger opened 2 years ago

mkrueger commented 2 years ago

Hi

I've tried to solve the keyboard shortcut problem and came accross the MASShortcut project. Really nice work. I tried a similiar approach using the deprecated TIS API.

However there is a reason apple dumped it: It doesn't work for all cases. For example that API doesn't map the cut/copy/command cmd+c,v,x correctly.

There is an easy to use API in NSEvent:

https://developer.apple.com/documentation/appkit/nsevent/3242717-characters

That can be used instead the old carbon API and seems to work in the use cases I tested. It behaves a bit different but it's the way to go for us. The TIS API fails for example cut/copy/paste cmd+cxv keys on cyrillic layouts.

Hope that helps.

Note: Just checked the korean keyboard. The characters from the event need always to be taken into account as well unfortunately. It's quite complex to get key bindings working correctly.

Note: Situation is worse the new api doesn't recognize shift+option+. on korean - but the TIS does. So it's needed to query both APIs :( - it's a mess. But it solveable if the characters from the event, the new API and TIS is combined.