From d36bbcf26cc9931550c6e9ad36939bed09d1bb42 Mon Sep 17 00:00:00 2001 From: Domenic Cassisi Date: Tue, 16 Jan 2018 08:17:57 +0100 Subject: [PATCH] Adds missing key code for Print Screen (#682) (#806) * Adds missing key code for Print Screen and update javadoc (#682) --- jme3-core/src/main/java/com/jme3/input/KeyInput.java | 10 ++++++++++ .../src/main/java/com/jme3/input/awt/AwtKeyInput.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/input/KeyInput.java b/jme3-core/src/main/java/com/jme3/input/KeyInput.java index 9ad78ed7b..8a0f72245 100644 --- a/jme3-core/src/main/java/com/jme3/input/KeyInput.java +++ b/jme3-core/src/main/java/com/jme3/input/KeyInput.java @@ -445,6 +445,16 @@ public interface KeyInput extends Input { * (J3100). */ public static final int KEY_UNLABELED = 0x97; + /** + * PrtScr key. + * Note: for use on keyboards with a PrtScr key that is + * separate from the SysRq key. Most keyboards combine + * SysRq and PrtScr so if the intent is to actually + * capture the user's desire to capture the screen + * then SysRq is the most likely scan code. + * Use PrtScr to catch the rest (laptops, mini-keyboards, etc.) + */ + public static final int KEY_PRTSCR = 0x9A; /** * Enter key (num pad). */ diff --git a/jme3-desktop/src/main/java/com/jme3/input/awt/AwtKeyInput.java b/jme3-desktop/src/main/java/com/jme3/input/awt/AwtKeyInput.java index ac4ff75eb..b27e29035 100644 --- a/jme3-desktop/src/main/java/com/jme3/input/awt/AwtKeyInput.java +++ b/jme3-desktop/src/main/java/com/jme3/input/awt/AwtKeyInput.java @@ -371,6 +371,8 @@ public class AwtKeyInput implements KeyInput, KeyListener { return KeyEvent.VK_ALT; //todo: location left case KEY_RMENU: return KeyEvent.VK_ALT; //todo: location right + case KEY_PRTSCR: + return KeyEvent.VK_PRINTSCREEN; } logger.log(Level.WARNING, "unsupported key:{0}", key); return 0x10000 + key; @@ -600,6 +602,8 @@ public class AwtKeyInput implements KeyInput, KeyListener { return KEY_LMENU; //Left vs. Right need to improve case KeyEvent.VK_META: return KEY_RCONTROL; + case KeyEvent.VK_PRINTSCREEN: + return KEY_PRTSCR; } logger.log( Level.WARNING, "unsupported key:{0}", key);