I'm using the GuiScreen keyTyped function in an extended class, because the search bar is in a Gui. This is the code that I currently have
public void keyTyped(char typedChar, int keyCode) {
if (focus) {
if (keyCode == 28) {
focus = false;
} else if (keyCode == 14) {
if (!typed.isEmpty()) {
typed = typed.substring(0, typed.length() - 1);
}
} else if (ChatAllowedCharacters.isAllowedCharacter(typedChar)) {
typed += typedChar;
}
}
}