8000 Add keypress event to todo example (#241) · sudhircw/pyscript@facdfdb · GitHub
[go: up one dir, main page]

Skip to content

Commit facdfdb

Browse files
Add keypress event to todo example (pyscript#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>
1 parent b84017d commit facdfdb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pyscriptjs/examples/todo.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313

1414
def add_task(*ags, **kws):
15+
# ignore empty task
16+
if not new_task_content.element.value:
17+
return None
18+
1519
# create task
1620
task_id = f"task-{len(tasks)}"
1721
task = {
@@ -44,3 +48,6 @@ def check_task(evt=None):
4448
def add_task_event(e):
4549
if e.key == "Enter":
4650
add_task()
51+
52+
53+
new_task_content.element.onkeypress = add_task_event

0 commit comments

Comments
 (0)
0