Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Window.request_keyboard' without showing keyboard #986

Closed
ZingBallyhoo opened this issue Jan 18, 2017 · 4 comments
Closed

'Window.request_keyboard' without showing keyboard #986

ZingBallyhoo opened this issue Jan 18, 2017 · 4 comments

Comments

@ZingBallyhoo
Copy link
Contributor

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?

@ZingBallyhoo
Copy link
Contributor Author

ZingBallyhoo commented Jan 18, 2017

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.

@inclement
Copy link
Member

Have you tried binding to Window.on_key_down?

@ZingBallyhoo
Copy link
Contributor Author

ZingBallyhoo commented Jan 18, 2017

@inclement Thanks! That does indeed work.

@z-huabao
Copy link

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants