aboutsummaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-11-04 16:16:28 +0100
committermetamuffin <metamuffin@disroot.org>2024-11-04 16:16:28 +0100
commit5f8b7352cd5231bc1151c3b3f5aaaef261747253 (patch)
treec4db442c9374515d90c376085049a48547ddb5af /script.js
parente93520702a78adba65eca3546fb815fd729469be (diff)
downloadabrechenbarkeit-5f8b7352cd5231bc1151c3b3f5aaaef261747253.tar
abrechenbarkeit-5f8b7352cd5231bc1151c3b3f5aaaef261747253.tar.bz2
abrechenbarkeit-5f8b7352cd5231bc1151c3b3f5aaaef261747253.tar.zst
refactor and user creating input redirect
Diffstat (limited to 'script.js')
-rw-r--r--script.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/script.js b/script.js
index 1a494b8..27de46e 100644
--- a/script.js
+++ b/script.js
@@ -1,10 +1,21 @@
/// <reference lib="dom" />
-document.addEventListener("keypress", ev => {
+document.addEventListener("keydown", ev => {
if (!(document.activeElement instanceof HTMLInputElement)) {
- if (ev.code.startsWith("Digit"))
- document.forms.buy_product.pcode.value += ev.code.substring(5)
- if (ev.code == "Enter")
- document.forms.buy_product.submit()
+ if (ev.code.startsWith("Digit")) {
+ if (document.forms.buy_product.pcode)
+ return document.forms.buy_product.pcode.value += ev.code.substring(5)
+ } else if (ev.code == "Enter") {
+ if (document.forms.buy_product)
+ return document.forms.buy_product.submit()
+ if (document.forms.user_creation)
+ return document.forms.user_creation.submit()
+ } else if (ev.code.startsWith("Key") || ev.code == "Space") {
+ if (document.forms.user_creation)
+ return document.forms.user_creation.create_user.value += ev.key
+ } else if (ev.code == "Backspace") {
+ if (document.forms.user_creation)
+ return document.forms.user_creation.create_user.value = ""
+ }
}
})