<script src="vopamoi.js" defer="true"></script>
</head>
<body onload="browserInit();">
- <form onsubmit="return BrowserUI.addTask(this);">
- <input id="taskName" name="taskName">
- </form>
+ <input id="taskName" name="taskName">
<div id="tasks"></div>
</body>
</html>
};
const BrowserUI = {
- addTask: function (form: any) {
- if (form.taskName.value) {
- UI.addTask(form.taskName.value);
- form.taskName.value = "";
+ addTask: function () {
+ const input = <HTMLInputElement>document.getElementById("taskName");
+ if (input.value) {
+ UI.addTask(input.value);
+ input.value = "";
}
- return false;
},
destroyTask: function () {
};
function handleKey(event: any) {
- if (event.target.tagName !== "INPUT") {
+ if (event.target.tagName === "INPUT") {
+ if (event.key == "Enter") return BrowserUI.addTask();
+ } else {
if (event.key == "j") return BrowserUI.moveCursor(1);
if (event.key == "k") return BrowserUI.moveCursor(-1);
if (event.key == "J") return BrowserUI.moveTask(1);