diff --git a/main.py b/main.py index 607549113..e1b7cdb93 100755 --- a/main.py +++ b/main.py @@ -391,7 +391,7 @@ def produce_plain_response(request): ui.link('Try yet another route!', '/another/route/1') -with example(ui.hotkey): +with example(ui.keyboard): def handle_keys(e): if e.key == 'f' and not e.key.repeat: if e.action.keyup: @@ -408,7 +408,7 @@ def handle_keys(e): elif e.key.down: ui.notify('going down') - hotkeys = ui.hotkey(handle_keys) - ui.label('Key events can be caught globally by using the hotkey element.') + keyboard = ui.keyboard(handle_keys) + ui.label('Key events can be caught globally by using the keyboard element.') ui.run(port=8080) diff --git a/nicegui/elements/hotkey.js b/nicegui/elements/keyboard.js similarity index 97% rename from nicegui/elements/hotkey.js rename to nicegui/elements/keyboard.js index 4ff9403c5..d478ebdf6 100644 --- a/nicegui/elements/hotkey.js +++ b/nicegui/elements/keyboard.js @@ -1,4 +1,4 @@ -Vue.component('hotkey', { +Vue.component('keyboard', { template: ``, methods: { add_event_listeners() { diff --git a/nicegui/elements/hotkey.py b/nicegui/elements/keyboard.py similarity index 72% rename from nicegui/elements/hotkey.py rename to nicegui/elements/keyboard.py index fc378840f..68e026d57 100644 --- a/nicegui/elements/hotkey.py +++ b/nicegui/elements/keyboard.py @@ -5,24 +5,24 @@ from ..utils import handle_exceptions, provide_arguments -class HotkeyView(CustomView): +class KeyboardView(CustomView): def __init__(self, handle_keys: Callable): - super().__init__('hotkey', __file__, activeJSEvents=['keydown', 'keyup', 'keypress']) + super().__init__('keyboard', __file__, activeJSEvents=['keydown', 'keyup', 'keypress']) self.allowed_events = ['keyboardEvent'] self.style = 'display: none' self.initialize(temp=False, on_keyboardEvent=handle_exceptions(provide_arguments(handle_keys, 'key_data', 'event_type'))) -class Hotkey(Element): +class Keyboard(Element): def __init__(self, handle_keys: Callable = None): """ - Hotkeys + Keyboard Adds global keyboard event tracking. :param handle_keys: callback to be executed when keyboard events occur. """ - super().__init__(HotkeyView(handle_keys=handle_keys)) + super().__init__(KeyboardView(handle_keys=handle_keys)) diff --git a/nicegui/ui.py b/nicegui/ui.py index db397b4c0..300146c6a 100644 --- a/nicegui/ui.py +++ b/nicegui/ui.py @@ -36,7 +36,7 @@ class Ui: from .elements.row import Row as row from .elements.column import Column as column from .elements.card import Card as card - from .elements.hotkey import Hotkey as hotkey + from .elements.keyboard import Keyboard as keyboard from .elements.card import CardSection as card_section from .timer import Timer as timer