Relative Content

Tag Archive for swiftmacoskeyboard

Intercept the power button press event using on an macOS app using swift and swiftUI

I am writing a small macOS app in which the app intercept all the keyboard events and nullify them.I use CGEventType to achieve this goal, but CGEventType does not include the power button on macbook. When I press the power button, the app is unable to intercept. So I wonder if there is a way to include the power button too. Big thanks in acvance.