package cz.moneta.test.harness.support.web;

public enum Key implements CharSequence {

    BACK_SPACE('\uE003'),
    TAB('\uE004'),
    ENTER('\uE007'),
    SHIFT('\uE008'),
    CONTROL('\uE009'),
    ALT('\uE00A'),
    ESCAPE('\uE00C'),
    SPACE('\uE00D'),
    PAGE_UP('\uE00E'),
    PAGE_DOWN('\uE00F'),
    END('\uE010'),
    HOME('\uE011'),
    LEFT('\uE012'),
    UP('\uE013'),
    RIGHT('\uE014'),
    DOWN('\uE015'),
    INSERT('\uE016'),
    DELETE('\uE017'),

    // Function keys
    F1('\uE031'),
    F2('\uE032'),
    F3('\uE033'),
    F4('\uE034'),
    F5('\uE035'),
    F6('\uE036'),
    F7('\uE037'),
    F8('\uE038'),
    F9('\uE039'),
    F10('\uE03A'),
    F11('\uE03B'),
    F12('\uE03C'),

    //ALPHABET
    A('a'),
    B('b'),
    C('c'),
    D('d'),
    E('e'),
    F('f'),
    G('g'),
    H('h'),
    I('i'),
    J('j'),
    K('k'),
    L('l'),
    M('m'),
    N('n'),
    O('o'),
    P('p'),
    Q('q'),
    R('r'),
    S('s'),
    T('t'),
    U('u'),
    V('v'),
    W('w'),
    X('x'),
    Y('y'),
    Z('z'),

    //NUMBERS
    NUMBER_1('1'),
    NUMBER_2('2'),
    NUMBER_3('3'),
    NUMBER_4('4'),
    NUMBER_5('5'),
    NUMBER_6('6'),
    NUMBER_7('7'),
    NUMBER_8('8'),
    NUMBER_9('9'),
    NUMBER_0('0');

    private final char keyCode;

    Key(char keyCode) {
        this.keyCode = keyCode;
    }

    public char charAt(int index) {
        if (index == 0) {
            return keyCode;
        }
        return 0;
    }

    public int length() {
        return 1;
    }

    public CharSequence subSequence(int start, int end) {
        if (start == 0 && end == 1) {
            return String.valueOf(keyCode);
        }
        throw new IndexOutOfBoundsException();
    }

    @Override
    public String toString() {
        return String.valueOf(keyCode);
    }

}