@@ -14,6 +14,12 @@ const MODIFIER_KEY_IDS = new Set([
1414 'AltLeft' , 'AltRight' , 'MetaLeft' , 'MetaRight' , 'ContextMenu' ,
1515] ) ;
1616
17+ const MOD_KEY_FAMILY = {
18+ ShiftLeft : 'Shift' , ShiftRight : 'Shift' ,
19+ ControlLeft : 'Ctrl' , ControlRight : 'Ctrl' ,
20+ AltLeft : 'Alt' , AltRight : 'Alt' ,
21+ } ;
22+
1723function buildModDefs ( settings ) {
1824 const { splitModifiers } = settings ;
1925 if ( splitModifiers ) {
@@ -62,6 +68,21 @@ export default function BindModal({
6268
6369 const newId = bindingId ( keyId , modifiers ) ;
6470
71+ const currentFamily = MOD_KEY_FAMILY [ keyId ] ;
72+ const hasConflict = ( ( ) => {
73+ if ( currentFamily && modifiers . length === 0 ) {
74+ return existingBindings . some ( b => b . modifiers . some ( m => MOD_FAMILY [ m ] === currentFamily ) ) ;
75+ }
76+ if ( modifiers . length > 0 ) {
77+ const usedFamilies = new Set ( modifiers . map ( m => MOD_FAMILY [ m ] ) . filter ( Boolean ) ) ;
78+ return existingBindings . some ( b => {
79+ const fam = MOD_KEY_FAMILY [ b . key ] ;
80+ return fam && b . modifiers . length === 0 && usedFamilies . has ( fam ) ;
81+ } ) ;
82+ }
83+ return false ;
84+ } ) ( ) ;
85+
6586 useEffect ( ( ) => {
6687 if ( inputRef . current ) inputRef . current . focus ( ) ;
6788 const existing = existingBindings . find ( b => bindingId ( b . key , b . modifiers ) === newId ) ;
@@ -212,6 +233,10 @@ export default function BindModal({
212233 </ div >
213234 </ div >
214235
236+ { hasConflict && (
237+ < p className = "conflict-warn" > ⚠ { t ( 'modifierConflict' ) } </ p >
238+ ) }
239+
215240 < div className = "modal-actions" >
216241 < button type = "button" className = "btn-secondary" onClick = { onCancel } > { t ( 'cancel' ) } </ button >
217242 < button type = "submit" className = "btn-primary" > { t ( 'save' ) } </ button >
0 commit comments