To get the deleted characters you can use plain old javascript:
var caret_get_position = function(element){
var pos = 0;
var posEnd = 0;
if('selectionStart' in element){
pos = element.selectionStart;
posEnd = element.selectionEnd;
}else if('selection' in document){
element.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;
Sel.moveStart('character', -element.value.length);
pos = Sel.text.length-SelLength;
posEnd = Sel.text.length;
}
// return both selection start and end;
return [pos, posEnd];
};
//get deletet character
element.addEventListener('keydown', function(event){
var keycode = ('which' in event)?event.which:event.keyCode;
caret_positions = caret_get_position(element);
var val = this.value;
if(keycode == 8){
if(caret_positions[0] == caret_positions[1]){
if(caret_positions[0] == 0){
deleted = '';
}else{
deleted = val.substr(caret_positions[0]-1, 1);
}
}else{
deleted = val.substring(caret_positions[0], caret_positions[1]);
}
}else if(keycode == 46){
if(caret_positions[0] == caret_positions[1]){
if(caret_positions[0] === val.length){
deleted = '';
}else{
deleted = val.substr(caret_positions[0], 1);
}
}else{
deleted = val.substring(caret_positions[0], caret_positions[1]);
}
}
});
So the hell am i doing here:
caret_get_position
is pretty much self-explanatory. It will get the current position of the caret (the blinking line in your inputfield). Even with a selected range (this blue stuff) if you select more than one character.
In the keydown event it will check the pressed key and some more checks where the caret is.
In the end the deleted characters are in the variable deleted
. This is from my code so you need to adjust it for your needs.