我正在def _on_keyboard_down
和python-2.7
中使用kivy
。当我在键盘上按1,2,3时,然后打印text
奇怪的字符,如ā,Ă,±。有人可以帮我吗?
def _on_keyboard_down(self, instance, keyboard, keycode, text, modifiers):
print(text)
答案 0 :(得分:1)
替换
_on_keyboard_down(self, instance, keyboard, keycode, text, modifiers):
与
_on_keyboard_down(self, window, keycode, scancode, text, modifiers):
The keycode 49 have been pressed
- text is '1'
- modifiers are []
- window= <kivy.core.window.window_sdl2.WindowSDL object at 0x7f91dc381180>
- scancode= 30
The keycode 257 have been pressed
- text is 'ā'
- modifiers are []
- window= <kivy.core.window.window_sdl2.WindowSDL object at 0x7f91dc381180>
- scancode= 89
The key 258 have been pressed
- text is 'Ă'
- modifiers are []
- window= <kivy.core.window.window_sdl2.WindowSDL object at 0x7f91dc381180>
- scancode= 90
已按下键码259 -文字为“ă” -修饰符为[] -窗口= -scancode = 91
按下数字1的键盘时,键码为49。
按下NumPad键盘时,键码= 257表示数字1,键码= 258表示数字2,键码= 259表示数字3,依此类推。