import java.util.HashMap;
import java.util.Map;

public final class Main {

    private static final Runnable DO_NOTHING = () -> {};

    private final Map<Character, Runnable> map;

    public Main() {
        map = new HashMap<>();
        map.put('h', () -> moveCursorLeft());
        map.put('j', () -> moveCursorUp());
        map.put('k', () -> moveCursorDown());
        map.put('l', () -> moveCursorRight());
    }

    private void handleKeyInput() {
        var c = getPressedKey();
        // Of course, you can pass the method reference to an empty method
        // instead of 'DO_NOTHING'.
        var action = map.getOrDefault(c, DO_NOTHING);
        action.run();
        // In fact, you don't need 'action' and can write:
        //
        // map.getOrDefault(c, DO_NOTHING)
        //     .run();
    }

    /**
        Returns the character of the pressed key.
        If no key is pressed, blocks until any key is pressed.

        @return
            The character of the pressed key.
    */
    private char getPressedKey() {
        return 'a';
    }

    private void moveCursorRight() {}
    private void moveCursorUp() {}
    private void moveCursorDown() {}
    private void moveCursorLeft() {}

    public static void main(String[] args) {
        var m = new Main();
        m.handleKeyInput();
    }
}
