--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java 2017-09-08 15:06:29.978698300 +0530 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CRobot.java 2017-09-08 15:06:28.805590600 +0530 @@ -166,6 +166,42 @@ } /** + * Presses a given key. + *

+ * Key codes that have more than one physical key associated with them + * (e.g. {@code KeyEvent.VK_SHIFT} could mean either the + * left or right shift key) will map to the left key. + *

+ * Assumes that the + * peer implementations will throw an exception for other bogus + * values e.g. -1, 999999 + * + * @param keycode the key to press (e.g. {@code KeyEvent.VK_A}) + */ + @Override + public void keyPressUnicode(final int key) { + keyEventUnicode(key, true); + } + + /** + * Releases a given key. + *

+ * Key codes that have more than one physical key associated with them + * (e.g. {@code KeyEvent.VK_SHIFT} could mean either the + * left or right shift key) will map to the left key. + *

+ * Assumes that the + * peer implementations will throw an exception for other bogus + * values e.g. -1, 999999 + * + * @param keycode the key to release (e.g. {@code KeyEvent.VK_A}) + */ + @Override + public void keyReleaseUnicode(final int key) { + keyEventUnicode(key, false); + } + + /** * Returns the color of a pixel at the given screen coordinates. * @param x X position of pixel * @param y Y position of pixel @@ -198,6 +234,7 @@ boolean isButtonsDownState, boolean isMouseMove); private native void keyEvent(int javaKeyCode, boolean keydown); + private native void keyEventUnicode(int javaKeyCode, boolean keydown); private void getScreenPixels(Rectangle r, int[] pixels){ double scale = fDevice.getScaleFactor(); nativeGetScreenPixels(r.x, r.y, r.width, r.height, scale, pixels);