The Scanner class should be able to read those characters.

Look at KeyListeners for a way to receive notification when a key is pressed.

The rest is up to your program to execute your code to...