Keyboard.Modifier commandModifier = Platform.getCommandModifier();
if (keyCode == Keyboard.KeyCode.DELETE
|| keyCode == Keyboard.KeyCode.BACKSPACE) {
boolean backspace = (keyCode == Keyboard.KeyCode.DELETE ? false : true);
Validator validator = textInput.getValidator();
boolean strictValidation = textInput.isStrictValidation();
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 (backspace) {
index--;
}
if (index >= 0
&& index < textNode.getCharacterCount()) {
buf.deleteCharAt(index);
}
}
if (validator.isValid(buf.toString())) {
textInput.delete(backspace);
} else {
Toolkit.getDefaultToolkit().beep();
}
} else {