Sha256: 7826ce1d8130e994f8c6dc87fefa0ea291820c7aa282f671e5fb6c5b99eeb578
Contents?: true
Size: 1.06 KB
Versions: 15
Compression:
Stored size: 1.06 KB
Contents
$(() => { const $inputs = $("input[data-autojump]"); const DELETE_KEY_CODE = 8; // Initialize $inputs.on("keydown", (event) => { // Do not do anything if there is selected text if (event.target.selectionStart !== event.target.selectionEnd) { return; } if (event.originalEvent.key.length === 1 && event.target.dataset.jumpNext) { if ( event.target.value.length === parseInt(event.target.dataset.maxLength, 10) ) { event.preventDefault(); setTimeout(() => { const next = $(event.target.dataset.jumpNext); next.val(event.originalEvent.key); next.trigger("focus"); }, 1); } } else if ( event.originalEvent.keyCode === DELETE_KEY_CODE && event.target.dataset.jumpPrev ) { if (event.target.value.length === 0) { event.preventDefault(); setTimeout(() => { const prev = $(event.target.dataset.jumpPrev); prev.val(prev.val().slice(0, -1)); prev.trigger("focus"); }, 1); } } }); });
Version data entries
15 entries across 15 versions & 1 rubygems