pythonmodulekeyboardcustom-keyboardkeyboard-layout

Stop user from typing using the onscreen keyboard Python


I am looking to create an onscreen keyboard using Python. The onscreen keyboard should be there only for visual representation. The user should not be able to use the onscreen keyboard to type text. If the user presses a key on the physical keyboard, the same key on the virtual keyboard should change colour for a few seconds.

I have found that I can create this keyboard using the keyboardlayout module and customize the keyboard to suit my needs. However, I am unable to find a way to stop the user from using the onscreen keyboard to type. Because of this, I looked for a different Python module to create the keyboard. I found that the msvcrt module can be used to stop the user from typing. However, this module stops the user from typing on the virtual and physical keyboards.

Are there any modules that can be used to stop the user only from typing using the onscreen keyboard created using the keyboardlayout module. If there are no modules available which allow me to stop the user form typing using only the onscreen keyboard, would I be able to create a custom module which stops the user from typing text using the onscreen keyboard.


Solution

  • You could use the PySimpleGui to create the keyboard. This will allow you to create a custom keyboard which contains all of the keys that you want to include. You will need to input the keyboard characters yourself.

    Use these lines within the _keyboardhandler function of the keyboard class to stop the user from entering text using the onscreen keyboard:

    class keyboard (self):
        def _keyboardhandler(self):
            if self.event is not None:
                if self.event == 'close':
                    self.hide()