KeyPress io KeyDown

This commit is contained in:
2017-04-29 13:28:46 +02:00
parent 60381af65f
commit 1cf9f2598e
6 changed files with 11 additions and 13 deletions

View File

@@ -1,10 +1,7 @@
package nl.astraeus.komp.todo
import kotlinx.html.*
import kotlinx.html.js.onClickFunction
import kotlinx.html.js.onDoubleClickFunction
import kotlinx.html.js.onKeyDownFunction
import kotlinx.html.js.section
import kotlinx.html.js.*
import nl.astraeus.komp.HtmlComponent
import nl.astraeus.komp.Komp
import org.w3c.dom.HTMLElement
@@ -120,13 +117,14 @@ class TodoApp: HtmlComponent() {
id = "todo_input"
placeholder = "What needs to be done?"
autoFocus = true
onKeyDownFunction = { e ->
onKeyPressFunction = { e ->
if (e is KeyboardEvent && e.keyCode == 13) {
addTodo(e)
}
}
}
}
section(classes = "main") {
input(classes = "toggle-all") {
type = InputType.checkBox
@@ -145,7 +143,7 @@ class TodoApp: HtmlComponent() {
classes += "editing"
input(classes = "edit") {
value = todo.title
onKeyDownFunction = { e ->
onKeyPressFunction = { e ->
if (e is KeyboardEvent && e.keyCode == 13) {
editTodo(e, todo)
}
@@ -183,6 +181,7 @@ class TodoApp: HtmlComponent() {
}
}
}
footer(classes = "footer") {
span(classes = "todo-count") {
strong { + "${getItemsLeft()}" }