in in Input field, if the user presses Backspace or Delete key, is there a way to get the deleted character.
I need to check it against a RegExp.
If you have deleted a character by mistake, unfortunately we are unable to recover it.
Yes, within 120 days of deletion. If a character doesn't appear on your list, it means it was purged from the database because it was below level 50 and it was deleted too long ago. Purged characters cannot be restored by any means.
Yes, within 120 days of deletion. After the above retention periods, deleted characters are purged from the database and will no longer be visible on the character restoration list.
Assuming the input box has an id 'input'. Here is how with least amount of code you can find out the last character from the input box.
document.getElementById("input").onkeydown = function(evt) {
const t = evt.target;
if (evt.keyCode === 8) { // for backspace key
console.log(t.value[t.selectionStart - 1]);
} else if (evt.keyCode === 46) { // for delete key
console.log(t.value[t.selectionStart]);
}
};
<input id="input" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With