I'm trying to create an app where the user can type some text in a TextInput, and press a button to register the data. Is it possible to bind the Enter key, so the user can just press it inside the Text Input and it calls the register function?
Asked
Active
Viewed 443 times
0
-
[This isn't an identical question](https://stackoverflow.com/questions/49727988/python-kivy-form-submit-using-enter-key), but you may find it useful for reference. – Ari Cooper-Davis Oct 26 '19 at 14:35
1 Answers
0
If it's a single line TextInput you can you can set the TextInput.multiline
property to False
then the Enter key emits a TextInput.on_text_validate()
event. For example:
from kivy.uix.textinput import TextInput
textinput = TextInput(text='Hello world')
def on_enter(instance, value):
print('User pressed enter in', instance)
textinput = TextInput(text='Hello world', multiline=False)
textinput.bind(on_text_validate=on_enter)
This is in Kivy's TextInput documentation.

Ari Cooper-Davis
- 3,374
- 3
- 26
- 43