fliegendewurst.eu/static/kv/snippets/kv-a60e45f081a1ffa1/base.js
FliegendeWurst cfe9a124b6 Update kv
2023-11-09 11:38:46 +01:00

24 lines
593 B
JavaScript

function handleTextChange(event) {
const target = event.target;
const value = target.value;
if (value.length == 0) {
target.value = "-";
} else {
target.value = value.substr(value.length - 1);
}
}
function handleTextScroll(event) {
const target = event.target;
const value = target.value;
if (event.deltaY < 0) {
target.value = "1"; // scroll up
} else {
target.value = "0"; // scroll down
}
event.preventDefault();
}
export function attachTypeListener(element) {
element.addEventListener("input", handleTextChange);
element.addEventListener("wheel", handleTextScroll);
}