001package squidpony.squidgrid.gui.gdx;
002
003import com.badlogic.gdx.Gdx;
004import com.badlogic.gdx.Input;
005import com.badlogic.gdx.InputAdapter;
006import com.badlogic.gdx.utils.CharArray;
007
008/**
009 * This input processing class can handle mouse and keyboard input, using a squidpony.squidgrid.gui.gdx.SquidMouse for
010 * Mouse input and a user implementation of the SquidInput.KeyHandler interface to react to keys represented as chars
011 * and the modifiers those keys were pressed with, any of alt, ctrl, and/or shift. Not all keys are representable by
012 * default in unicode, so symbolic representations are stored in constants in this class, and are passed to
013 * KeyHandler.handle() as chars like DOWN_ARROW or its value, '\u2193'. Shift modifies the input as it would on a
014 * QWERTY keyboard, and the exact mapping is documented in fromKey() as well. This class handles mouse input
015 * immediately, but stores keypresses in a queue, storing all key events and allowing them to be processed one at a time
016 * using next() or all at once using drain(). To have an effect, it needs to be registered by calling
017 * Input.setInputProcessor(SquidInput).
018 *
019 * It does not perform the blocking functionality of earlier SquidKey implementations, because this is meant to run
020 * in an event-driven libGDX game and should not step on the toes of libGDX's input handling. To block game logic
021 * until an event has been received, check hasNext() in the game's render() method and effectively "block" by not
022 * running game logic if hasNext() returns false. You can process an event if hasNext() returns true by calling next().
023 * Mouse inputs do not affect hasNext(), and next() will process only key pressed events.
024 *
025 * @author Eben Howard - http://squidpony.com - howard@squidpony.com
026 * @author Nathan Sweet
027 * @author Tommy Ettinger
028 * */
029public class SquidInput extends InputAdapter {
030    /**
031     * A single-method interface used to process "typed" characters, special characters produced by unusual keys, and
032     * modifiers that can affect them. SquidInput has numerous static char values that are expected to be passed
033     * to handle() in place of the special keys (such as arrow keys) that do not have a standard char value.
034     */
035    public interface KeyHandler{
036        /**
037         * The only method you need to implement yourself in KeyHandler, this should react to keys such as
038         * 'a' (produced by pressing the A key while not holding Shift), 'E' (produced by pressing the E key while
039         * holding Shift), and '\u2190' (left arrow in unicode, also available as a constant in SquidInput, produced by
040         * pressing the left arrow key even though that key does not have a default unicode representation). Capital
041         * letters will be capitalized when they are passed to this, but they may or may not have the shift argument as
042         * true depending on how this method was called. Symbols that may be produced by holding Shift and pressing a
043         * number or a symbol key can vary between keyboards (some may require Shift to be held down, others may not).
044         * <br>
045         * This can react to the input in whatever way you find appropriate for your game.
046         * @param key a char of the "typed" representation of the key, such as 'a' or 'E', or if there is no Unicode
047         *            character for the key, an appropriate alternate character as documented in SquidInput.fromKey()
048         * @param alt true if the Alt modifier was being held while this key was entered, false otherwise.
049         * @param ctrl true if the Ctrl modifier was being held while this key was entered, false otherwise.
050         * @param shift true if the Shift modifier was being held while this key was entered, false otherwise.
051         */
052        void handle(char key, boolean alt, boolean ctrl, boolean shift);
053    }
054
055    protected KeyHandler keyAction;
056    protected boolean numpadDirections = true, ignoreInput = false;
057    protected SquidMouse mouse;
058    protected final CharArray queue = new CharArray();
059    protected final CharArray processingQueue = new CharArray();
060
061    /**
062     * Constructs a new SquidInput that does not respond to keyboard or mouse input. These can be set later by calling
063     * setKeyHandler() to allow keyboard handling or setMouse() to allow mouse handling on a grid.
064     */
065    public SquidInput() {
066        keyAction = null;
067        mouse = new SquidMouse(12, 12, new InputAdapter());
068    }
069
070    /**
071     * Constructs a new SquidInput that does not respond to keyboard input, but does take mouse input and passes mouse
072     * events along to the given SquidMouse. The SquidMouse, even though it is an InputProcessor on its own, should not
073     * be registered by calling Input.setInputProcessor(SquidMouse), and instead this object should be registered by
074     * calling Input.setInputProcessor(SquidInput). The keyboard and mouse handling can be changed later by calling
075     * setKeyHandler() to allow keyboard handling or setMouse() to change mouse handling.
076     * @param mouse a SquidMouse instance that will be used for handling mouse input. Must not be null.
077     */
078    public SquidInput(SquidMouse mouse) {
079        keyAction = null;
080        this.mouse = mouse;
081    }
082
083
084    /**
085     * Constructs a new SquidInput that does not respond to mouse input, but does take keyboard input and sends keyboard
086     * events through some processing before calling keyHandler.handle() on keypresses that can sensibly be processed.
087     * Modifier keys do not go through the same processing but are checked for their current state when the key is
088     * pressed, and the states of alt, ctrl, and shift are passed to keyHandler.handle() as well.
089     * You can use setMouse() to allow mouse handling or change the KeyHandler with setKeyHandler().
090     * @param keyHandler must implement the SquidInput.KeyHandler interface so it can handle() key input.
091     */
092    public SquidInput(KeyHandler keyHandler) {
093        keyAction = keyHandler;
094        mouse = new SquidMouse(12, 12, new InputAdapter());
095    }
096    /**
097     * Constructs a new SquidInput that does not respond to mouse input, but does take keyboard input and sends keyboard
098     * events through some processing before calling keyHandler.handle() on keypresses that can sensibly be processed.
099     * Modifier keys do not go through the same processing but are checked for their current state when the key is
100     * pressed, and the states of alt, ctrl, and shift are passed to keyHandler.handle() as well.
101     * You can use setMouse() to allow mouse handling or change the KeyHandler with setKeyHandler().
102     * @param keyHandler must implement the SquidInput.KeyHandler interface so it can handle() key input.
103     * @param ignoreInput true if this should ignore input initially, false if it should process input normally.
104     */
105    public SquidInput(KeyHandler keyHandler, boolean ignoreInput) {
106        keyAction = keyHandler;
107        mouse = new SquidMouse(12, 12, new InputAdapter());
108        this.ignoreInput = ignoreInput;
109    }
110    /**
111     * Constructs a new SquidInput that responds to mouse and keyboard input when given a SquidMouse and a
112     * SquidInput.KeyHandler implementation. It sends keyboard events through some processing before calling
113     * keyHandler.handle() on keypresses that can sensibly be processed. Modifier keys do not go through the same
114     * processing but are checked for their current state when the key is pressed, and the states of alt, ctrl, and
115     * shift are passed to keyHandler.handle() as well. The SquidMouse, even though it is an
116     * InputProcessor on its own, should not be registered by calling Input.setInputProcessor(SquidMouse), and instead
117     * this object should be registered by calling Input.setInputProcessor(SquidInput). You can use setKeyHandler() or
118     * setMouse() to change keyboard or mouse handling.
119     * @param keyHandler must implement the SquidInput.KeyHandler interface so it can handle() key input.
120     * @param mouse a SquidMouse instance that will be used for handling mouse input. Must not be null.
121     */
122    public SquidInput(KeyHandler keyHandler, SquidMouse mouse) {
123        keyAction = keyHandler;
124        this.mouse = mouse;
125    }
126
127    /**
128     * Constructs a new SquidInput that responds to mouse and keyboard input when given a SquidMouse and a
129     * SquidInput.KeyHandler implementation, and can be put in an initial state where it ignores input until told
130     * otherwise via setIgnoreInput(boolean). It sends keyboard events through some processing before calling
131     * keyHandler.handle() on keypresses that can sensibly be processed. Modifier keys do not go through the same
132     * processing but are checked for their current state when the key is pressed, and the states of alt, ctrl, and
133     * shift are passed to keyHandler.handle() as well. The SquidMouse, even though it is an
134     * InputProcessor on its own, should not be registered by calling Input.setInputProcessor(SquidMouse), and instead
135     * this object should be registered by calling Input.setInputProcessor(SquidInput). You can use setKeyHandler() or
136     * setMouse() to change keyboard or mouse handling.
137     * @param keyHandler must implement the SquidInput.KeyHandler interface so it can handle() key input.
138     * @param mouse a SquidMouse instance that will be used for handling mouse input. Must not be null.
139     * @param ignoreInput true if this should ignore input initially, false if it should process input normally.
140     */
141    public SquidInput(KeyHandler keyHandler, SquidMouse mouse, boolean ignoreInput) {
142        keyAction = keyHandler;
143        this.mouse = mouse;
144        this.ignoreInput = ignoreInput;
145    }
146
147    public void setKeyHandler(KeyHandler keyHandler)
148    {
149        keyAction = keyHandler;
150    }
151    public void setMouse(SquidMouse mouse)
152    {
153        this.mouse = mouse;
154    }
155
156    public boolean isUsingNumpadDirections() {
157        return numpadDirections;
158    }
159
160    public void setUsingNumpadDirections(boolean using) {
161        numpadDirections = using;
162    }
163
164    public KeyHandler getKeyHandler() {
165        return keyAction;
166    }
167
168    public SquidMouse getMouse() {
169        return mouse;
170    }
171
172    /**
173     * Get the status for whether this should ignore input right now or not. True means this object will ignore and not
174     * queue input, false means it should process them normally. Useful to pause processing or delegate it to
175     * another object temporarily.
176     * @return true if this object currently ignores input, false otherwise.
177     */
178    public boolean getIgnoreInput() {
179        return ignoreInput;
180    }
181
182    /**
183     * Set the status for whether this should ignore input right now or not. True means this object will ignore and not
184     * queue input, false means it should process them normally. Useful to pause processing or delegate it to
185     * another object temporarily.
186     * @param ignoreInput true if this should object should ignore and not queue input, false otherwise.
187     */
188    public void setIgnoreInput(boolean ignoreInput) {
189        this.ignoreInput = ignoreInput;
190    }
191
192    /**
193     * Processes all events queued up, passing them through this object's key processing and then to keyHandler. Mouse
194     * events are not queued and are processed when they come in.
195     */
196    public void drain () {
197        CharArray q = processingQueue;
198
199        if (keyAction == null || queue.size < 2) {
200            queue.clear();
201            return;
202        }
203        q.addAll(queue);
204        queue.clear();
205
206        for (int i = 0, n = q.size; i < n; ) {
207            char c = q.get(i++), mods = q.get(i++);
208            keyAction.handle(c, (mods & 1) != 0, (mods & 2) != 0, (mods & 4) != 0);
209        }
210        /**
211         case KEY_UP:
212         keyProcessor.keyUp(q.get(i++));
213         break;
214         */
215
216        q.clear();
217    }
218
219    /**
220     * Returns true if at least one event is queued.
221     * @return true if there is an event queued, false otherwise.
222     */
223    public boolean hasNext()
224    {
225        return queue.size >= 2;
226    }
227
228    /**
229     * Processes the first key event queued up, passing it to this object's InputProcessor. Mouse events are not
230     * queued and are processed when they come in.
231     */
232    public void next() {
233        CharArray q = processingQueue;
234        if (keyAction == null || queue.size < 2) {
235            queue.clear();
236            return;
237        }
238        q.addAll(queue, 0, 2);
239        queue.removeRange(0, 1);
240
241        if (q.size >= 2) {
242            char c = q.get(0), mods = q.get(1);
243            keyAction.handle(c, (mods & 1) != 0, (mods & 2) != 0, (mods & 4) != 0);
244        }
245        q.clear();
246    }
247
248    /**
249     * Empties the backing queue of data.
250     */
251    public void flush()
252    {
253        queue.clear();
254    }
255
256    @Override
257        public boolean keyDown (int keycode) {
258        if(ignoreInput) return false;
259        boolean alt =  Gdx.input.isKeyPressed(Input.Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.ALT_RIGHT),
260                ctrl =  Gdx.input.isKeyPressed(Input.Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Input.Keys.CONTROL_RIGHT),
261                shift = Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.SHIFT_RIGHT);
262        char c = fromCode(keycode, shift);
263        char mods = 0;
264        if(c != '\0') {
265            queue.add(c);
266            mods |= (alt) ? 1 : 0;
267            mods |= (ctrl) ? 2 : 0;
268            mods |= (shift) ? 4 : 0;
269            queue.add(mods);
270        }
271        return false;
272    }
273
274    @Override
275        public boolean keyUp (int keycode) {
276//        queue.add(KEY_UP);
277//        queue.add(keycode);
278        return false;
279    }
280
281    @Override
282        public boolean keyTyped (char character) {
283        return false;
284    }
285
286    @Override
287        public boolean touchDown (int screenX, int screenY, int pointer, int button) {
288        if(ignoreInput) return false;
289        return mouse.touchDown(screenX, screenY, pointer, button);
290    }
291
292    @Override
293        public boolean touchUp (int screenX, int screenY, int pointer, int button) {
294        if(ignoreInput) return false;
295        return mouse.touchUp(screenX, screenY, pointer, button);
296    }
297
298    @Override
299        public boolean touchDragged (int screenX, int screenY, int pointer) {
300        if(ignoreInput) return false;
301        return mouse.touchDragged(screenX, screenY, pointer);
302    }
303
304    @Override
305        public boolean mouseMoved (int screenX, int screenY) {
306        if(ignoreInput) return false;
307        return mouse.mouseMoved(screenX, screenY);
308    }
309
310    @Override
311        public boolean scrolled (int amount) {
312        if(ignoreInput) return false;
313        return mouse.scrolled(amount);
314    }
315
316    /**
317     * Maps keycodes to unicode chars, sometimes depending on whether the Shift key is held.
318     *
319     * It is strongly recommended that you refer to key combinations regarding non-alphabet keys by using, for example,
320     * Ctrl-Shift-; instead of Ctrl-:, that is to use the unshifted key with Shift instead of assuming that all
321     * keyboards will use the QWERTY layout. Pressing shift while pressing just about any representable symbol will map
322     * to the shifted version as if on a QWERTY keyboard, and if you don't have a QWERTY keyboard, the mappings are
323     * documented in full below.
324     *
325     * Keys 'a' to 'z' report 'A' to 'Z' when shift is held. Non-Latin characters are not supported, since most
326     * keyboards would be unable to send keys for a particular language and A-Z are very common.
327     *
328     * Top row numbers map as follows:
329     *
330     * '1' to '!', '2' to '@', '3' to '#', '4' to '$', '5' to '%',
331     * '6' to '^', '7' to '&amp;', '8' to '*', '9' to '(', '0' to ')'
332     *
333     * Numpad numbers will report a SquidInput constant such as UP_LEFT_ARROW for Numpad 7, but only if numpadDirections
334     * is true; otherwise they send the number (here, 7). Numpad 0 sends VERTICAL_ARROW or 0.
335     *
336     * Most symbol keys are mapped to a single unicode char as a constant in SquidInput and disregard Shift. The
337     * constant is usually the same as the name of the char; possible exceptions are Backspace (on PC) or Delete (on
338     * Mac) mapping to BACKSPACE, Delete (on PC) mapping to FORWARD_DELETE, Esc mapping to ESCAPE, and Enter (on PC) or
339     * Return (on Mac) mapping to ENTER.
340     *
341     * ':', '*', '#', '@', and space keys, if present, always map to themselves, regardless of Shift.
342     *
343     * Other characters map as follows when Shift is held, as they would on a QWERTY keyboard:
344     *
345     * ',' to '&lt;'
346     *
347     * '.' to '&gt;'
348     *
349     * '/' to '?'
350     *
351     * ';' to ':'
352     *
353     * '\'' to '&quot;'
354     *
355     * '[' to '{'
356     *
357     * ']' to '}'
358     *
359     * '|' to '\\'
360     *
361     * '-' to '_'
362     *
363     * '+' to '='
364     *
365     * '`' to '~'
366     *
367     * @param keycode a keycode as passed by LibGDX
368     * @param shift true if Shift key is being held.
369     * @return
370     */
371    public char fromCode(int keycode, boolean shift)
372    {
373        switch (keycode) {
374            case Input.Keys.HOME:
375                return HOME;
376            case Input.Keys.FORWARD_DEL:
377                return FORWARD_DELETE;
378            case Input.Keys.ESCAPE:
379                return ESCAPE;
380            case Input.Keys.END:
381                return END;
382
383            case Input.Keys.UP:
384                return UP_ARROW;
385            case Input.Keys.DOWN:
386                return DOWN_ARROW;
387            case Input.Keys.LEFT:
388                return LEFT_ARROW;
389            case Input.Keys.RIGHT:
390                return RIGHT_ARROW;
391            case Input.Keys.CENTER:
392                return CENTER_ARROW;
393
394            case Input.Keys.NUM_0:
395                return (shift) ? ')' : '0';
396            case Input.Keys.NUM_1:
397                return (shift) ? '!' : '1';
398            case Input.Keys.NUM_2:
399                return (shift) ? '@' : '2';
400            case Input.Keys.NUM_3:
401                return (shift) ? '#' : '3';
402            case Input.Keys.NUM_4:
403                return (shift) ? '$' : '4';
404            case Input.Keys.NUM_5:
405                return (shift) ? '%' : '5';
406            case Input.Keys.NUM_6:
407                return (shift) ? '^' : '6';
408            case Input.Keys.NUM_7:
409                return (shift) ? '&' : '7';
410            case Input.Keys.NUM_8:
411                return (shift) ? '*' : '8';
412            case Input.Keys.NUM_9:
413                return (shift) ? '(' : '9';
414            case Input.Keys.NUMPAD_0:
415                return (numpadDirections) ? VERTICAL_ARROW : '0';
416            case Input.Keys.NUMPAD_1:
417                return (numpadDirections) ? DOWN_LEFT_ARROW : '1';
418            case Input.Keys.NUMPAD_2:
419                return (numpadDirections) ? DOWN_ARROW : '2';
420            case Input.Keys.NUMPAD_3:
421                return (numpadDirections) ? DOWN_RIGHT_ARROW : '3';
422            case Input.Keys.NUMPAD_4:
423                return (numpadDirections) ? LEFT_ARROW : '4';
424            case Input.Keys.NUMPAD_5:
425                return (numpadDirections) ? CENTER_ARROW : '5';
426            case Input.Keys.NUMPAD_6:
427                return (numpadDirections) ? RIGHT_ARROW : '6';
428            case Input.Keys.NUMPAD_7:
429                return (numpadDirections) ? UP_LEFT_ARROW : '7';
430            case Input.Keys.NUMPAD_8:
431                return (numpadDirections) ? UP_ARROW : '8';
432            case Input.Keys.NUMPAD_9:
433                return (numpadDirections) ? UP_RIGHT_ARROW : '9';
434            case Input.Keys.COLON:
435                return ':';
436            case Input.Keys.STAR:
437                return '*';
438            case Input.Keys.POUND:
439                return '#';
440            case Input.Keys.A:
441                return (shift) ? 'A' : 'a';
442            case Input.Keys.B:
443                return (shift) ? 'B' : 'b';
444            case Input.Keys.C:
445                return (shift) ? 'C' : 'c';
446            case Input.Keys.D:
447                return (shift) ? 'D' : 'd';
448            case Input.Keys.E:
449                return (shift) ? 'E' : 'e';
450            case Input.Keys.F:
451                return (shift) ? 'F' : 'f';
452            case Input.Keys.G:
453                return (shift) ? 'G' : 'g';
454            case Input.Keys.H:
455                return (shift) ? 'H' : 'h';
456            case Input.Keys.I:
457                return (shift) ? 'I' : 'i';
458            case Input.Keys.J:
459                return (shift) ? 'J' : 'j';
460            case Input.Keys.K:
461                return (shift) ? 'K' : 'k';
462            case Input.Keys.L:
463                return (shift) ? 'L' : 'l';
464            case Input.Keys.M:
465                return (shift) ? 'M' : 'm';
466            case Input.Keys.N:
467                return (shift) ? 'N' : 'n';
468            case Input.Keys.O:
469                return (shift) ? 'O' : 'o';
470            case Input.Keys.P:
471                return (shift) ? 'P' : 'p';
472            case Input.Keys.Q:
473                return (shift) ? 'Q' : 'q';
474            case Input.Keys.R:
475                return (shift) ? 'R' : 'r';
476            case Input.Keys.S:
477                return (shift) ? 'S' : 's';
478            case Input.Keys.T:
479                return (shift) ? 'T' : 't';
480            case Input.Keys.U:
481                return (shift) ? 'U' : 'u';
482            case Input.Keys.V:
483                return (shift) ? 'V' : 'v';
484            case Input.Keys.W:
485                return (shift) ? 'W' : 'w';
486            case Input.Keys.X:
487                return (shift) ? 'X' : 'x';
488            case Input.Keys.Y:
489                return (shift) ? 'Y' : 'y';
490            case Input.Keys.Z:
491                return (shift) ? 'Z' : 'z';
492            case Input.Keys.COMMA:
493                return (shift) ? '<' : ',';
494            case Input.Keys.PERIOD:
495                return (shift) ? '>' :'.';
496            case Input.Keys.TAB:
497                return TAB;
498            case Input.Keys.SPACE:
499                return ' ';
500            case Input.Keys.ENTER:
501                return ENTER;
502            case Input.Keys.BACKSPACE:
503                return BACKSPACE; // also DEL
504            case Input.Keys.GRAVE:
505                return (shift) ? '~' : '`';
506            case Input.Keys.MINUS:
507                return (shift) ? '_' : '-';
508            case Input.Keys.EQUALS:
509                return (shift) ? '+' :'=';
510            case Input.Keys.LEFT_BRACKET:
511                return (shift) ? '{' :'[';
512            case Input.Keys.RIGHT_BRACKET:
513                return (shift) ? '}' :']';
514            case Input.Keys.BACKSLASH:
515                return (shift) ? '|' :'\\';
516            case Input.Keys.SEMICOLON:
517                return (shift) ? ':' :';';
518            case Input.Keys.APOSTROPHE:
519                return (shift) ? '"' :'\'';
520            case Input.Keys.SLASH:
521                return (shift) ? '?' :'/';
522            case Input.Keys.AT:
523                return '@';
524            case Input.Keys.PAGE_UP:
525                return PAGE_UP;
526            case Input.Keys.PAGE_DOWN:
527                return PAGE_DOWN;
528            case Input.Keys.BUTTON_A:
529                return GAMEPAD_A;
530            case Input.Keys.BUTTON_B:
531                return GAMEPAD_B;
532            case Input.Keys.BUTTON_C:
533                return GAMEPAD_C;
534            case Input.Keys.BUTTON_X:
535                return GAMEPAD_X;
536            case Input.Keys.BUTTON_Y:
537                return GAMEPAD_Y;
538            case Input.Keys.BUTTON_Z:
539                return GAMEPAD_Z;
540            case Input.Keys.BUTTON_L1:
541                return GAMEPAD_L1;
542            case Input.Keys.BUTTON_R1:
543                return GAMEPAD_R1;
544            case Input.Keys.BUTTON_L2:
545                return GAMEPAD_L2;
546            case Input.Keys.BUTTON_R2:
547                return GAMEPAD_R2;
548            case Input.Keys.BUTTON_THUMBL:
549                return GAMEPAD_LEFT_THUMB;
550            case Input.Keys.BUTTON_THUMBR:
551                return GAMEPAD_RIGHT_THUMB;
552            case Input.Keys.BUTTON_START:
553                return GAMEPAD_START;
554            case Input.Keys.BUTTON_SELECT:
555                return GAMEPAD_SELECT;
556            case Input.Keys.INSERT:
557                return INSERT;
558
559            case Input.Keys.F1:
560                return F1;
561            case Input.Keys.F2:
562                return F2;
563            case Input.Keys.F3:
564                return F3;
565            case Input.Keys.F4:
566                return F4;
567            case Input.Keys.F5:
568                return F5;
569            case Input.Keys.F6:
570                return F6;
571            case Input.Keys.F7:
572                return F7;
573            case Input.Keys.F8:
574                return F8;
575            case Input.Keys.F9:
576                return F9;
577            case Input.Keys.F10:
578                return F10;
579            case Input.Keys.F11:
580                return F11;
581            case Input.Keys.F12:
582                return F12;
583            default:
584                return '\0';
585        }
586
587    }
588
589    /**
590     * Left arrow key. If numpadDirections is enabled, this will also be sent by Numpad 4.
591     */
592    public static final char LEFT_ARROW = '\u2190';
593    /**
594     * Up arrow key. If numpadDirections is enabled, this will also be sent by Numpad 8.
595     */
596    public static final char UP_ARROW = '\u2191';
597    /**
598     * Down arrow key. If numpadDirections is enabled, this will also be sent by Numpad 6.
599     */
600    public static final char RIGHT_ARROW = '\u2192';
601    /**
602     * Down arrow key. If numpadDirections is enabled, this will also be sent by Numpad 2.
603     */
604    public static final char DOWN_ARROW = '\u2193';
605    /**
606     * Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 1.
607     */
608    public static final char DOWN_LEFT_ARROW = '\u2199';
609    /**
610     * Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 3.
611     */
612    public static final char DOWN_RIGHT_ARROW = '\u2198';
613    /**
614     * Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 9.
615     */
616    public static final char UP_RIGHT_ARROW = '\u2197';
617    /**
618     * Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 7.
619     */
620    public static final char UP_LEFT_ARROW = '\u2196';
621    /**
622     * Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 5.
623     */
624    public static final char CENTER_ARROW = '\u21BA';
625    /**
626     * Not typically a dedicated key, but if numpadDirections is enabled, this will be sent by Numpad 0.
627     *
628     * Intended for games that might need up a jump or crouch button on the numpad that supplants movement.
629     */
630    public static final char VERTICAL_ARROW = '\u2195';
631    /**
632     * Enter key, also called Return key. Used to start a new line of text or confirm entries in forms.
633     */
634    public static final char ENTER = '\u21B5';
635    /**
636     * Tab key. Used for entering horizontal spacing, such as indentation, but also often to cycle between menu items.
637     */
638    public static final char TAB = '\u21B9';
639    /**
640     * Backspace key on most PC keyboards; Delete key on Mac keyboards. Used to delete the previous character.
641     */
642    public static final char BACKSPACE = '\u2280';
643    /**
644     * Delete key on most PC keyboards; no equivalent on some (all?) Mac keyboards. Used to delete the next character.
645     *
646     * Not present on some laptop keyboards and some (all?) Mac keyboards.
647     */
648    public static final char FORWARD_DELETE = '\u2281';
649    /**
650     * Insert key. Not recommended for common use because it could affect other application behavior.
651     *
652     * Not present on some laptop keyboards.
653     */
654    public static final char INSERT = '\u2208';
655    /**
656     * Page Down key.
657     *
658     * Not present on some laptop keyboards.
659     */
660    public static final char PAGE_DOWN = '\u22A4';
661    /**
662     * Page Up key.
663     *
664     * Not present on some laptop keyboards.
665     */
666    public static final char PAGE_UP = '\u22A5';
667    /**
668     * Home key (commonly used for moving a cursor to start of line).
669     *
670     * Not present on some laptop keyboards.
671     */
672    public static final char HOME = '\u2302';
673    /**
674     * End key (commonly used for moving a cursor to end of line).
675     *
676     * Not present on some laptop keyboards.
677     */
678    public static final char END = '\u2623';
679    /**
680     * Esc or Escape key
681     */
682    public static final char ESCAPE = '\u2620';
683
684    /**
685     * Function key F1
686     */
687    public static final char F1 = '\u2460';
688    /**
689     * Function key F2
690     */
691    public static final char F2 = '\u2461';
692    /**
693     * Function key F3
694     */
695    public static final char F3 = '\u2462';
696    /**
697     * Function key F4
698     */
699    public static final char F4 = '\u2463';
700    /**
701     * Function key F5
702     */
703    public static final char F5 = '\u2464';
704    /**
705     * Function key F6
706     */
707    public static final char F6 = '\u2465';
708    /**
709     * Function key F7
710     */
711    public static final char F7 = '\u2466';
712    /**
713     * Function key F8
714     */
715    public static final char F8 = '\u2467';
716    /**
717     * Function key F9
718     */
719    public static final char F9 = '\u2468';
720    /**
721     * Function key F10
722     */
723    public static final char F10 = '\u2469';
724    /**
725     * Function key F11
726     */
727    public static final char F11 = '\u246A';
728    /**
729     * Function key F12
730     */
731    public static final char F12 = '\u246B';
732
733    /**
734     * Gamepad A button.
735     */
736    public static final char GAMEPAD_A = '\u24b6';
737    /**
738     * Gamepad B button.
739     */
740    public static final char GAMEPAD_B = '\u24b7';
741    /**
742     * Gamepad C button.
743     */
744    public static final char GAMEPAD_C = '\u24b8';
745    /**
746     * Gamepad X button.
747     */
748    public static final char GAMEPAD_X = '\u24cd';
749    /**
750     * Gamepad Y button.
751     */
752    public static final char GAMEPAD_Y = '\u24ce';
753    /**
754     * Gamepad Z button.
755     */
756    public static final char GAMEPAD_Z = '\u24cf';
757
758    /**
759     * Gamepad L1 button.
760     */
761    public static final char GAMEPAD_L1 = '\u24c1';
762    /**
763     * Gamepad L2 button.
764     */
765    public static final char GAMEPAD_L2 = '\u24db';
766    /**
767     * Gamepad R1 button.
768     */
769    public static final char GAMEPAD_R1 = '\u24c7';
770    /**
771     * Gamepad R2 button.
772     */
773    public static final char GAMEPAD_R2 = '\u24e1';
774    /**
775     * Gamepad Left Thumb button.
776     */
777    public static final char GAMEPAD_LEFT_THUMB = '\u24a7';
778    /**
779     * Gamepad Right Thumb button.
780     */
781    public static final char GAMEPAD_RIGHT_THUMB = '\u24ad';
782    /**
783     * Gamepad Start button.
784     */
785    public static final char GAMEPAD_START = '\u2713';
786    /**
787     * Gamepad Select button.
788     */
789    public static final char GAMEPAD_SELECT = '\u261C';
790
791
792}