mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-22 19:53:00 -05:00
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:
@@ -12,6 +12,10 @@ new_task_content = Element("new-task-content")
|
|||||||
|
|
||||||
|
|
||||||
def add_task(*ags, **kws):
|
def add_task(*ags, **kws):
|
||||||
|
# ignore empty task
|
||||||
|
if not new_task_content.element.value:
|
||||||
|
return None
|
||||||
|
|
||||||
# create task
|
# create task
|
||||||
task_id = f"task-{len(tasks)}"
|
task_id = f"task-{len(tasks)}"
|
||||||
task = {
|
task = {
|
||||||
@@ -44,3 +48,6 @@ def add_task(*ags, **kws):
|
|||||||
def add_task_event(e):
|
def add_task_event(e):
|
||||||
if e.key == "Enter":
|
if e.key == "Enter":
|
||||||
add_task()
|
add_task()
|
||||||
|
|
||||||
|
|
||||||
|
new_task_content.element.onkeypress = add_task_event
|
||||||
|
|||||||
Reference in New Issue
Block a user