Caret (^) does not register immediately. Java key listener

I am currently building a calculator in Java and have started implementing
a key listener. It works very well, but when I try to type the caret symbol (^) it doesn't register immediately. You have to press another key first to make it appear.

I guess the reason for this is that it uses the same behavior as when you try to type a caret
in a regular text document. But is there any way to come around this behavior?

The issue is that the input keyboard layout you are using on your computer treats ^ as a dead key, as it is a combining diacritic. The way to fix this would be to change your input keyboard layout to a keyboard that does not treat ^ as a combining diacritic. This can be tested by typing ^ + e and seeing if it results in ê or ^e.