abrechenbarkeit/script.js

26 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-11-03 17:38:21 +00:00
/// <reference lib="dom" />
document.addEventListener("keydown", ev => {
2024-11-04 15:24:41 +00:00
if (ev.ctrlKey || ev.altKey) return
2024-11-03 17:38:21 +00:00
if (!(document.activeElement instanceof HTMLInputElement)) {
if (ev.code.startsWith("Digit")) {
2024-11-04 15:24:41 +00:00
if (document.forms.buy_product)
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 = ""
2024-11-04 15:24:41 +00:00
} else if (ev.code == "Escape") {
window.location.href = "/"
ev.preventDefault()
}
2024-11-03 17:38:21 +00:00
}
})