onkeypress change key

Hey everyone,

I’m trying to chance the key when a certain key is pressed with the following code:

private void keyDownEvent(KeyDownEvent e, TextField textField){
	Key key =e.getCode().get();
	Key key2 = e.getKey();
		//method doesn't exist..

Unfortunately more things are going wrong here. The if is never true, it doesn’t matter if I use the key or key2 variable here.
Then there is the thing of change the character that’s being added to as tring somewhere. (could also be in the middle of the string…).

Does anyone know how to handle this?

Kind regards,

So now I finally got the key I want, but I want to switch it to the comma without using setvalue (as that triggers on value change and that deletes everything thats typed inside the textfield) see:

private void keyDownEvent(KeyDownEvent e, TextField numberField){
	List<String> pressedkey = e.getCode().get().getKeys();
	List<String> spaceKeys =Key.NUMPAD_DECIMAL.getKeys();
	for(String key : pressedkey){
		//need this to work