Skip to content

Commit

Permalink
Merge pull request #616 from zonble/dev/handle_key_up
Browse files Browse the repository at this point in the history
Handle key up events during active input state.
  • Loading branch information
zonble authored Feb 25, 2025
2 parents e227f6c + ff4369c commit 704bd94
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/InputMethodController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class McBopomofoInputMethodController: IMKInputController {
}

override func recognizedEvents(_ sender: Any!) -> Int {
let events: NSEvent.EventTypeMask = [.keyDown, .flagsChanged]
let events: NSEvent.EventTypeMask = [.keyDown, .keyUp, .flagsChanged]
return Int(events.rawValue)
}

Expand All @@ -162,6 +162,19 @@ class McBopomofoInputMethodController: IMKInputController {
return false
}

if event.type == .flagsChanged {
if state is InputState.Empty {
return false
}
// Handle key up events during active input state.
//
// This prevents double-space from affecting the current input.
// While macOS may normally insert a period on double space, this
// should be suppressed when there is an active composing buffer or
// candidate window.
return true
}

if event.type == .flagsChanged {
let functionKeyKeyboardLayoutID = Preferences.functionKeyboardLayout
let basisKeyboardLayoutID = Preferences.basisKeyboardLayout
Expand Down

0 comments on commit 704bd94

Please sign in to comment.