Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/pynput/keyboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def press(self, key):
:param key: The key being pressed.
:type key: Key or KeyCode
"""
if key in self._keys and key not in self._state:
if key not in self._state:
self._state.add(key)
if self._state == self._keys:
self._on_activate()
Expand All @@ -193,7 +193,7 @@ def release(self, key):

class GlobalHotKeys(Listener):
"""A keyboard listener supporting a number of global hotkeys.

This is a convenience wrapper to simplify registering a number of global
hotkeys.

Expand Down
5 changes: 4 additions & 1 deletion tests/keyboard_hotkey_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ def test_hotkeys(self):
q = queue.Queue()

with GlobalHotKeys({
'<ctrl>+a': lambda: q.put('x'),
'<ctrl>+<shift>+a': lambda: q.put('a'),
'<ctrl>+<shift>+b': lambda: q.put('b'),
'<ctrl>+<shift>+c': lambda: q.put('c')}):

notify('Press <ctrl>+<shift>+a')
self.assertNotEqual('x', q.get())
self.assertEqual('a', q.get())

notify('Press <ctrl>+<shift>+b')
self.assertEqual('b', q.get())

Expand Down