I am not very advanced as a programmer and I'm trying to build an app in Kivy, and I ran into something I can't explain (on Mac OS X). Running this program from an answer from How to handle several keys pressed at the same time in Kivy?, for example, press and hold h and spacebar both, and then press j, k, l, or ' does not create keyup or keydown events. However, ; does. Also press and hold j and f and press v and m do not create events, but all the other keys on the bottom row do. There are other examples as well. I have not been able to find a reference to explain this. From experimenting I am guessing that on my system there is a maximum of six keys that can be pressed and held at once with all of them creating events, but it's not consistent nor do I know why there is an upper limit. Can anyone explain this? And does anyone know how to make the keyboard work as advertised, so that in Kivy keyboard events are created no matter how many keys are pressed in whatsoever order?
#!/usr/bin/env python3
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.scatter import Scatter
from kivy.core.window import Window
class MyApp(App):
def __init__(self, **kwargs):
super(MyApp, self).__init__(**kwargs)
self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
self._keyboard.bind(on_key_down = self._on_keyboard_down)
self._keyboard.bind(on_key_up = self._on_keyboard_up)
def _keyboard_closed(self):
self._keyboard.unbind(on_key_down = self._on_keyboard_down)
self._keyboard = None
def _on_keyboard_down(self, *args):
print('down', args)
def _on_keyboard_up(self, *args):
print('up', args)
def build(self):
self.moveable = Scatter()
self.moveable.add_widget( Label(text = 'Hello moving world!') )
return self.moveable
if __name__ == '__main__':
MyApp().run()