Hi David - just stumbled on this 2.5 years later while trying to add keyboard shortcuts to my app… For the benefit of others landing here, and not to denigrate your mousetrap solution (which I’m happy to say still works even today!), here’s an alternative solution that also includes Hover and Focus:
As a third option, I came up with this quick and dirty approach based on creating an ‘invisible’ TextBox hidden in your form layout. Several big limitations, but if you want to return basic keyboard input with a simple copy/paste of pure Anvil+Python, it might do the job for you:
def __init__(self, **properties):
# Set Form properties and Data Bindings.
# Make an 'invisible' textbox that blends in with your form design
self.text_box_1.foreground = self.text_box_1.background = '#ffffff'
self.text_box_1.border = "hidden"
def text_box_1_change(self, **event_args):
"""This method is called when the text in this text box is edited"""
self.text_box_1.text = ""
def text_box_1_show(self, **event_args):
"""This method is called when the TextBox is shown on the screen"""
# Remember to then set the Show and Change events in your Design panel