Skip to content

'Window.request_keyboard' without showing keyboard #986

Closed

Description

@ZingBallyhoo

Hello.

What I am trying to achieve is listening for key events (on_key_down, on_key_up) without the keyboard showing (not listening for keys that can be typed on the keyboard, D-Pad events that are passed through the keyboard provider (DPAD_UP,DPAD_DOWN,DPAD_LEFT,DPAD_RIGHT,DPAD_CENTER))

Receiving the actual events works fine, but only when the keyboard is showing. I need it to not show the keyboard, and still be able to receive the events. (opens when Window.request_keyboard, stops receiving events after you close the keyboard)

Demo program

Anyone know if this is possible?

Activity

  1. ZingBallyhoo commented on Jan 18, 2017

    @ZingBallyhoo
    ContributorAuthor

    Update:

    I have been able to get events after the keyboard is hidden by the user, by removing unbind from the widget._keyboard_closed. I still don't know how to not make the keyboard show at all.

  2. inclement commented on Jan 18, 2017

    @inclement
    Member

    Have you tried binding to Window.on_key_down?

  3. ZingBallyhoo commented on Jan 18, 2017

    @ZingBallyhoo
    ContributorAuthor

    @inclement Thanks! That does indeed work.

  4. z-huabao commented on Apr 22, 2019

    @z-huabao

    @ZingBallyhoo hello, can you tell me how to "binding to Window.on_key_down" in code billow:

    class MyKeyboardListener(Widget):
        def __init__(self, **kwargs):
            super(MyKeyboardListener, self).__init__(**kwargs)
            self._keyboard = Window.request_keyboard(self._keyboard_closed, self, 'text')
            self._keyboard.bind(on_key_down=self._on_keyboard_down)
    
        def _keyboard_closed(self):
            print('My keyboard have been closed!')
            self._keyboard.unbind(on_key_down=self._on_keyboard_down)
            self._keyboard = None
    
        def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
            print('The key', keycode, 'have been pressed')
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions