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