diff --git a/Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSKeyboardEventMonitor.mm b/Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSKeyboardEventMonitor.mm index 8d4f8ab13e..73656cab0d 100644 --- a/Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSKeyboardEventMonitor.mm +++ b/Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSKeyboardEventMonitor.mm @@ -66,6 +66,7 @@ @interface PLSKeyboardEventMonitor () @property(weak) NSView* view; @property plInputManager* inputManager; @property(retain) id localMonitor; +@property BOOL capsLockKeyDown; @end @@ -152,10 +153,12 @@ - (BOOL)processKeyEvent:(NSEvent*)event if (keycode == kVK_Control) { down = (event.modifierFlags & NSEventModifierFlagControl) != 0; } - if (keycode == kVK_CapsLock) { - down = (event.modifierFlags & NSEventModifierFlagCapsLock) != 0; + BOOL capsLockMaskPresent = (event.modifierFlags & NSEventModifierFlagCapsLock) != 0; + if (capsLockMaskPresent != self.capsLockKeyDown) { + self.capsLockKeyDown = capsLockMaskPresent; + self.inputManager->HandleKeyEvent((plKeyDef)kVK_CapsLock, self.capsLockKeyDown, false); } - + /* This gets weird. Recent Apple hardware is starting to have its system key shortcuts assigned to the fn key @@ -174,8 +177,11 @@ - (BOOL)processKeyEvent:(NSEvent*)event } @synchronized(self.view.layer) { - self.inputManager->HandleKeyEvent( - (plKeyDef)keycode, down, event.type == NSEventTypeFlagsChanged ? false : event.ARepeat); + // Caps lock modifer has special handling that was earlier + if (keycode != kVK_CapsLock) { + self.inputManager->HandleKeyEvent( + (plKeyDef)keycode, down, event.type == NSEventTypeFlagsChanged ? false : event.ARepeat); + } if (!(modifierFlags & NSEventModifierFlagFunction) && down) { if (event.type != NSEventTypeFlagsChanged && event.characters.length > 0) { // Only works for BMP code points (up to U+FFFF), but that's unlikely to matter at