@@ -955,10 +955,61 @@ final class Miri: NSObject, NSMenuDelegate, @unchecked Sendable {
955955 }
956956
957957 private func normalizedKeybindingCandidates( modifiers: CGEventFlags , keyCode: Int64 , keyText: String ) -> [ String ] {
958- let modifierParts = normalizedModifierParts ( from: modifiers)
959- return normalizedKeyNames ( keyCode: keyCode, keyText: keyText) . map { keyName in
960- ( modifierParts + [ keyName] ) . joined ( separator: " + " )
958+ var candidates : [ String ] = [ ]
959+ let appendCandidates : ( [ String ] , [ String ] ) -> Void = { modifierParts, keyNames in
960+ for keyName in keyNames {
961+ let candidate = ( modifierParts + [ keyName] ) . joined ( separator: " + " )
962+ if !candidates. contains ( candidate) {
963+ candidates. append ( candidate)
964+ }
965+ }
966+ }
967+
968+ appendCandidates (
969+ normalizedModifierParts ( from: modifiers) ,
970+ normalizedKeyNames (
971+ keyCode: keyCode,
972+ keyText: keyText,
973+ includeFnNavigationAliases: modifiers. contains ( . maskSecondaryFn)
974+ )
975+ )
976+
977+ if modifiers. contains ( . maskSecondaryFn) {
978+ var legacyModifiers = modifiers
979+ legacyModifiers. remove ( . maskSecondaryFn)
980+ appendCandidates (
981+ normalizedModifierParts ( from: legacyModifiers) ,
982+ normalizedKeyNames ( keyCode: keyCode, keyText: keyText, includeFnNavigationAliases: false )
983+ )
961984 }
985+
986+ return candidates
987+ }
988+
989+ private func normalizedKeyNames( keyCode: Int64 , keyText: String , includeFnNavigationAliases: Bool ) -> [ String ] {
990+ var names : [ String ] = [ ]
991+ let add : ( String ) -> Void = { name in
992+ let normalized = self . normalizedKeyName ( name)
993+ if !names. contains ( normalized) {
994+ names. append ( normalized)
995+ }
996+ }
997+
998+ if !keyText. isEmpty {
999+ add ( keyText)
1000+ }
1001+
1002+ for name in Self . keyNamesByCode [ keyCode] ?? [ ] {
1003+ add ( name)
1004+ }
1005+
1006+ if includeFnNavigationAliases {
1007+ for name in Self . fnNavigationKeyAliasesByCode [ keyCode] ?? [ ] {
1008+ add ( name)
1009+ }
1010+ }
1011+
1012+ return names
9621013 }
9631014
9641015 private func normalizedKeybinding( _ binding: String ) -> String ? {
@@ -1018,26 +1069,6 @@ final class Miri: NSObject, NSMenuDelegate, @unchecked Sendable {
10181069 [ " cmd " , " ctrl " , " shift " , " alt " , " fn " ] . filter { modifiers. contains ( $0) }
10191070 }
10201071
1021- private func normalizedKeyNames( keyCode: Int64 , keyText: String ) -> [ String ] {
1022- var names : [ String ] = [ ]
1023- let add : ( String ) -> Void = { name in
1024- let normalized = self . normalizedKeyName ( name)
1025- if !names. contains ( normalized) {
1026- names. append ( normalized)
1027- }
1028- }
1029-
1030- if !keyText. isEmpty {
1031- add ( keyText)
1032- }
1033-
1034- for name in Self . keyNamesByCode [ keyCode] ?? [ ] {
1035- add ( name)
1036- }
1037-
1038- return names
1039- }
1040-
10411072 private func normalizedKeyName( _ key: String ) -> String {
10421073 Self . keyNameAliases [ key. lowercased ( ) ] ?? key
10431074 }
@@ -1129,6 +1160,17 @@ final class Miri: NSObject, NSMenuDelegate, @unchecked Sendable {
11291160 KeyCode . f12: [ " f12 " ] ,
11301161 ]
11311162
1163+ private static let fnNavigationKeyAliasesByCode : [ Int64 : [ String ] ] = [
1164+ KeyCode . leftArrow: [ " home " ] ,
1165+ KeyCode . rightArrow: [ " end " ] ,
1166+ KeyCode . upArrow: [ " pageup " ] ,
1167+ KeyCode . downArrow: [ " pagedown " ] ,
1168+ KeyCode . home: [ " left " ] ,
1169+ KeyCode . end: [ " right " ] ,
1170+ KeyCode . pageUp: [ " up " ] ,
1171+ KeyCode . pageDown: [ " down " ] ,
1172+ ]
1173+
11321174 private static let keyNameAliases : [ String : String ] = [
11331175 // Brackets and braces.
11341176 " leftbracket " : " [ " ,
0 commit comments