diff options
author | William Holland <william.holland@codethink.co.uk> | 2015-05-31 15:33:46 +0100 |
---|---|---|
committer | William Holland <william.holland@codethink.co.uk> | 2015-05-31 15:33:46 +0100 |
commit | 57944355feefdedab20c85de0a784304712187b4 (patch) | |
tree | 8c8a404d1cbaefe9eca056c8cd334003e7013935 /keyboardpython | |
parent | c8e78ce217457e6790860c3b8da92aa83ac0002f (diff) | |
download | keyboard-python-57944355feefdedab20c85de0a784304712187b4.tar.bz2 |
Give Key and KeyCombination boolean values
Diffstat (limited to 'keyboardpython')
-rw-r--r-- | keyboardpython/key.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/keyboardpython/key.py b/keyboardpython/key.py index 24642e0..0a1414b 100644 --- a/keyboardpython/key.py +++ b/keyboardpython/key.py @@ -42,6 +42,9 @@ class KeyCombination: def __hash__(self): return hash(str(self)) + def __nonzero__(self): + return bool(self.keys()) + def contains_key(self,key): ''' is key in this combination? ''' if key in self.keys: return True @@ -98,6 +101,9 @@ class Key: def __str__(self): return self.name + def __nonzero__(self): + return bool(self.name) + # define modifier Keys ALT = Key('Alt') CTRL = Key('Control') |