当用户在我的应用程序中按下键盘上的Ctrl+Enter键时,我试图捕获:
class UI(Widget):
def __init__(self, **kwargs):
super(UI, self).__init__(**kwargs)
self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
self._keyboard.bind(on_key_down=self._on_keyboard_down)
def _keyboard_closed(self):
self._keyboard.unbind(on_key_down=self._on_keyboard_down)
self._keyboard = None
def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
if keycode[1] == 'w':
print("yes")
return False
return True
class UIApp(App):
def build(self):
return UI()
UIApp().run()
我意识到这段代码将捕获w
,但它甚至没有这样做。或者至少“是”不会打印到控制台。我的用户界面:
#:kivy 1.0.9
<UI>:
title: 'InputDialog'
auto_dismiss: False
RelativeLayout:
...
勾选
modifiers[0] == 'ctrl'
和keycode[0] == 13
或text is None
:相关问题 更多 >
编程相关推荐