Kivy/PyMongo: Using ‘enter’ key in TextInput to feed entered note into database

I am trying to make a part of an app where basically the person gets to leave small one-line reminders for themselves. I want to make sure that when the person presses ‘enter’, the note gets saved into the database.

This is my code in

class Reminders(Screen):
    collection = db['Notes']
    note_text = TextInput()
    note_num = collection.count_documents({})

    def add_note(self):
        self.note_text = TextInput(text='Note', size_hint=(0.2, 0.25), multiline=False, on_text_validate=self.keyboard_down)

    def keyboard_down(self, **kwargs):
        entry = {'_id': (self.note_num + 1), 'Note': self.note_text.text}


        text: "Reminders"
        color: (0, 0.702, 0, 1)
        font_size: 50
        pos_hint: {'x': 0.1, 'top': 1}
        size_hint: 0.2, 0.2

        text: 'Add'
        size_hint: 0.07, 0.07
        pos_hint: {'x': 0.78,'top': 0.94}
        on_release: root.add_note()

        size_hint: 0.96, 0.6
        pos_hint: {'x': 0.02, 'top': 0.7}
            id: layout
            orientation: 'tb-lr'

(These are all just little snippets of the code. The kv code is under the tag < Reminder >)

I am getting a Type Error >TypeError: keyboard_down() takes 1 positional argument but 2 were given

(The error occurs when I actually press enter). error


def keyboard_down(self, **kwargs):

Your function definition takes one positional argument, which you have named self. The error tells you that it’s being passed two positional arguments. You must change your definition to match how it’s called, e.g.

def keyboard_down(self, _, **kwargs):