From 62fcccf9512c75d9c405268981fc1be33419d72b Mon Sep 17 00:00:00 2001 From: Andrew Kay Date: Wed, 3 Jul 2019 20:35:04 -0500 Subject: [PATCH] Add MODIFIER_KEYS --- oec/keyboard.py | 2 ++ oec/vt100.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/oec/keyboard.py b/oec/keyboard.py index 3551bb6..5cd4d9b 100644 --- a/oec/keyboard.py +++ b/oec/keyboard.py @@ -281,6 +281,8 @@ KEY_MODIFIER_MAP = { Key.CAPS_LOCK: KeyboardModifiers.CAPS_LOCK } +MODIFIER_KEYS = set(KEY_MODIFIER_MAP.keys()) + Keymap = namedtuple('Keymap', ['name', 'default', 'shift', 'alt', 'modifier_release']) class Keyboard: diff --git a/oec/vt100.py b/oec/vt100.py index 6614d10..199d123 100644 --- a/oec/vt100.py +++ b/oec/vt100.py @@ -11,7 +11,7 @@ import pyte from .session import Session, SessionDisconnectedError from .display import encode_ascii_character -from .keyboard import Key, get_ascii_character_for_key +from .keyboard import Key, get_ascii_character_for_key, MODIFIER_KEYS VT100_KEY_MAP = { Key.NOT: b'^', @@ -130,8 +130,7 @@ class VT100Session(Session): if keyboard_modifiers.is_alt(): # Ignore any modifiers... this would fall through and result in a warning # if they are not explicitly ignored. - if key in [Key.LEFT_ALT, Key.RIGHT_ALT, Key.LEFT_SHIFT, Key.RIGHT_SHIFT, - Key.CAPS_LOCK]: + if key in MODIFIER_KEYS: return None bytes_ = VT100_KEY_MAP_ALT.get(key)