How to use USB numpad/keypad text input in Kivy on Android

398 Views Asked by At

Simply put, I would like to use a small USB keypad/numpad to type into a text input field on a kivy app running on android via the kivy launcher.

I am using an OTG USB connector to connect a small keypad to my tablet. The connector works in general on the tablet (I can type in numbers in the browser and other apps). In a kivy app however, when I use the touchscreen to select a text input field, it focuses awaiting input, then if I try to type in with the numpad, nothing happens. After doing some testing with a normal sized USB keyboard, it works (but the numpad on it doesn't).

Here is the basic kivy app I used to test this out with:

from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

KV = """

<MyScreenManager>:

    KeyboardInput:
        name: 'KeyInput'

<KeyboardInput>:
    GridLayout:
        rows: 3
        TextInput:
            id: input1
            text:''
            multiline: False        
        Widget:            
        TextInput:
            id: input2
            text:''
            multiline: False
"""

class KeyboardInput(Screen):
    pass


class MyScreenManager(ScreenManager):

    def changescreen(self, value):

        try:
            if value!='Go To...':
                self.current = value
        except:
            print('No screen named ' + value)

#Main application
class packagingDiscardmentApp(App):
    def build(self):
        Builder.load_string(KV)
        self.sm = MyScreenManager()
        return self.sm

if __name__ == '__main__':
    packagingDiscardmentApp().run()

My guess is that there is some issue with the ascii characters on the numpad and Kivy. Any help would be greatly appreciated.

0

There are 0 best solutions below