You can override the flagsChanged() method of NSViewController and have your code like below to detect fn key press and release in macOS:
You can ignore mouse events in a window/view by adding just a single line of code.
Like Delete key, detection of Escape key press is also slightly different than detecting general key presses.
You can quit or exit an app with:NSApp.terminate(self)
Delete key press detection is slightly different than other keys. It uses NSDeleteCharacter like below:
You can open your app’s window on top of all other open application windows with the below code:
Before launching the window, just use the appropriate window level, and you’re done.
Adding Global Keyboard Shortcuts to your macOS app can be a pain as there isn’t a Cocoa API for the same. You would have to rely on the old, most of which are deprecated, Carbon API.
For me personally, it is a mixed feeling working from home. On one hand, I have the flexibility with when to work and when not to but on the other hand, it is sometimes hard for me to find that fine line between work and life. There are days when I keep working even after office hours without realizing that I have got my life wife too :)