if (keyCode == Keyboard.KeyCode.DELETE
|| keyCode == Keyboard.KeyCode.BACKSPACE) {
Direction direction = (keyCode == Keyboard.KeyCode.DELETE ?
Direction.FORWARD : Direction.BACKWARD);
Validator validator = textInput.getValidator();
if (validator != null
&& strictValidation) {
StringBuilder buf = new StringBuilder(textNode.getText());
int index = textInput.getSelectionStart();
int count = textInput.getSelectionLength();
if (count > 0) {
buf.delete(index, index + count);
} else {
if (direction == Direction.BACKWARD) {
index--;
}
if (index >= 0
&& index < textNode.getCharacterCount()) {
buf.deleteCharAt(index);
}
}
if (validator.isValid(buf.toString())) {
textInput.delete(direction);
} else {
ApplicationContext.beep();
}
} else {