Skip to content

Commit

Permalink
Allow unbinding keys by pressing the same key.
Browse files Browse the repository at this point in the history
This is useful if you want to remove the "start chat" binding.
  • Loading branch information
Hoikas committed Mar 9, 2024
1 parent 3e60e76 commit 2c6e943
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Scripts/Python/xOptionsMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1810,8 +1810,12 @@ def ISetKeyMapping(self, controlCodeId: int, vkey: int, modifiers: int, isPrimar
km = ptKeyMap()
newKeyStr = km.convertVKeyToChar(vkey, modifiers)

# This will cause any previous uses of the key to be unbound.
# If this is the same key as before, unmap the binding.
controlCode = kControlCodes[controlCodeId]
if self.IGetBoundKey(controlCode, keyIdx=0 if isPrimary else 1) == newKeyStr:
newKeyStr = "(unmapped)"

# This will cause any previous uses of the key to be unbound.
if isinstance(controlCode, str):
PtDebugPrint(f"xOptionsMenu.ISetKeyMapping(): Binding {newKeyStr=} to console command {controlCode=}")
km.bindKeyToConsoleCommand(newKeyStr, controlCode)
Expand Down

0 comments on commit 2c6e943

Please sign in to comment.