As an experiment, I am trying to achieve the following:
- Let spacebar work as a modifier key - like the Shift key - where holding the spacebar key down and typing keys print different letters. Releasing the spacebar would set the state back to normal, and just pressing it behaves like a normal space key.
I was thinking of handling the keydown and keyup event, but apparently handleEvent:client:
in IMKServerInput Protocol seems to only catch key down and mouse events.
Without much experience with cocoa, I’ve tried some methods with no success:
- went through the Technical Note 2128 via internet archive, which gave me the suitable explanations of plist items. Still, nothing about keyup.
- tried adding NSKeyUpMask to
recognizedEvents:
in IMKStateSetting Protocol, but that didn’t seem to catch the event either. - tested a bit with addLocalMonitorForEventsMatchingMask:handler: but nothing happens.
- failed to find a way to make
NSFlagsChanged
event fire with spacebar. - read about Quartz Event Service and
CGEventTap
which seems to handle user inputs in lower level. Didn’t go further to this route, yet. - IOHIDManager?
I reached to a conclusion that IMKit is only capable of passively receiving events.
Since it is not an application, there is no keyUp:
method to override - AFAIK, IMKit does not inherit NSResponder
class.
Unfortunately cocoa is way too broad and has much less (or overflowed with non-helping) documentations for a novice like me to dive in.
Can anyone help me to the right direction?