Add keypress event to todo example (#241)

* add enter keypress event in todo example

* fix linting

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Allan Lago
2022-05-06 13:08:58 -04:00
committed by GitHub
parent b84017d191
commit facdfdb525

View File

@@ -12,6 +12,10 @@ new_task_content = Element("new-task-content")
def add_task(*ags, **kws):
# ignore empty task
if not new_task_content.element.value:
return None
# create task
task_id = f"task-{len(tasks)}"
task = {
@@ -44,3 +48,6 @@ def add_task(*ags, **kws):
def add_task_event(e):
if e.key == "Enter":
add_task()
new_task_content.element.onkeypress = add_task_event