jnativehook icon indicating copy to clipboard operation
jnativehook copied to clipboard

JavaFX KeyCode Maps.

Open DPachs opened this issue 2 years ago • 1 comments

Not exactly an issue, but recently i needed to use the library with Scala and JavaFX. Thanks for the amazing library by the way. Here's a Scala Map[Int, KeyCode] if someone needs it:

val nativeKey = Map(
      NativeKeyEvent.VC_ESCAPE -> KeyCode.ESCAPE,
      NativeKeyEvent.VC_F1 -> KeyCode.F1,
      NativeKeyEvent.VC_F2 -> KeyCode.F2,
      NativeKeyEvent.VC_F3 -> KeyCode.F3,
      NativeKeyEvent.VC_F4 -> KeyCode.F4,
      NativeKeyEvent.VC_F5 -> KeyCode.F5,
      NativeKeyEvent.VC_F6 -> KeyCode.F6,
      NativeKeyEvent.VC_F7 -> KeyCode.F7,
      NativeKeyEvent.VC_F8 -> KeyCode.F8,
      NativeKeyEvent.VC_F9 -> KeyCode.F9,
      NativeKeyEvent.VC_F10 -> KeyCode.F10,
      NativeKeyEvent.VC_F11 -> KeyCode.F11,
      NativeKeyEvent.VC_F12 -> KeyCode.F12,
      NativeKeyEvent.VC_F13 -> KeyCode.F13,
      NativeKeyEvent.VC_F14 -> KeyCode.F14,
      NativeKeyEvent.VC_F15 -> KeyCode.F15,
      NativeKeyEvent.VC_F16 -> KeyCode.F16,
      NativeKeyEvent.VC_F17 -> KeyCode.F17,
      NativeKeyEvent.VC_F18 -> KeyCode.F18,
      NativeKeyEvent.VC_F19 -> KeyCode.F19,
      NativeKeyEvent.VC_F20 -> KeyCode.F20,
      NativeKeyEvent.VC_F21 -> KeyCode.F21,
      NativeKeyEvent.VC_F22 -> KeyCode.F22,
      NativeKeyEvent.VC_F23 -> KeyCode.F23,
      NativeKeyEvent.VC_F24 -> KeyCode.F24,
      NativeKeyEvent.VC_BACKQUOTE -> KeyCode.BACK_QUOTE,
      NativeKeyEvent.VC_1 -> KeyCode.DIGIT1,
      NativeKeyEvent.VC_2 -> KeyCode.DIGIT2,
      NativeKeyEvent.VC_3 -> KeyCode.DIGIT3,
      NativeKeyEvent.VC_4 -> KeyCode.DIGIT4,
      NativeKeyEvent.VC_5 -> KeyCode.DIGIT5,
      NativeKeyEvent.VC_6 -> KeyCode.DIGIT6,
      NativeKeyEvent.VC_7 -> KeyCode.DIGIT7,
      NativeKeyEvent.VC_8 -> KeyCode.DIGIT8,
      NativeKeyEvent.VC_9 -> KeyCode.DIGIT9,
      NativeKeyEvent.VC_0 -> KeyCode.DIGIT0,
      NativeKeyEvent.VC_MINUS -> KeyCode.MINUS,
      NativeKeyEvent.VC_EQUALS -> KeyCode.EQUALS,
      NativeKeyEvent.VC_BACKSPACE -> KeyCode.BACK_SPACE,
      NativeKeyEvent.VC_TAB -> KeyCode.TAB,
      NativeKeyEvent.VC_CAPS_LOCK -> KeyCode.CAPS,
      NativeKeyEvent.VC_A -> KeyCode.A,
      NativeKeyEvent.VC_B -> KeyCode.B,
      NativeKeyEvent.VC_C -> KeyCode.C,
      NativeKeyEvent.VC_D -> KeyCode.D,
      NativeKeyEvent.VC_E -> KeyCode.E,
      NativeKeyEvent.VC_F -> KeyCode.F,
      NativeKeyEvent.VC_G -> KeyCode.G,
      NativeKeyEvent.VC_H -> KeyCode.H,
      NativeKeyEvent.VC_I -> KeyCode.I,
      NativeKeyEvent.VC_J -> KeyCode.J,
      NativeKeyEvent.VC_K -> KeyCode.K,
      NativeKeyEvent.VC_L -> KeyCode.L,
      NativeKeyEvent.VC_M -> KeyCode.M,
      NativeKeyEvent.VC_N -> KeyCode.N,
      NativeKeyEvent.VC_O -> KeyCode.O,
      NativeKeyEvent.VC_P -> KeyCode.P,
      NativeKeyEvent.VC_Q -> KeyCode.Q,
      NativeKeyEvent.VC_R -> KeyCode.R,
      NativeKeyEvent.VC_S -> KeyCode.S,
      NativeKeyEvent.VC_T -> KeyCode.T,
      NativeKeyEvent.VC_U -> KeyCode.U,
      NativeKeyEvent.VC_V -> KeyCode.V,
      NativeKeyEvent.VC_W -> KeyCode.W,
      NativeKeyEvent.VC_X -> KeyCode.X,
      NativeKeyEvent.VC_Y -> KeyCode.Y,
      NativeKeyEvent.VC_Z -> KeyCode.Z,
      NativeKeyEvent.VC_OPEN_BRACKET -> KeyCode.OPEN_BRACKET,
      NativeKeyEvent.VC_CLOSE_BRACKET -> KeyCode.CLOSE_BRACKET,
      NativeKeyEvent.VC_BACK_SLASH -> KeyCode.BACK_SLASH,
      NativeKeyEvent.VC_SEMICOLON -> KeyCode.SEMICOLON,
      NativeKeyEvent.VC_QUOTE -> KeyCode.QUOTE,
      NativeKeyEvent.VC_ENTER -> KeyCode.ENTER,
      NativeKeyEvent.VC_COMMA -> KeyCode.COMMA,
      NativeKeyEvent.VC_PERIOD -> KeyCode.PERIOD,
      NativeKeyEvent.VC_SLASH -> KeyCode.SLASH,
      NativeKeyEvent.VC_SPACE -> KeyCode.SPACE,
      NativeKeyEvent.VC_PRINTSCREEN -> KeyCode.PRINTSCREEN,
      NativeKeyEvent.VC_SCROLL_LOCK -> KeyCode.SCROLL_LOCK,
      NativeKeyEvent.VC_PAUSE -> KeyCode.PAUSE,
      NativeKeyEvent.VC_INSERT -> KeyCode.INSERT,
      NativeKeyEvent.VC_DELETE -> KeyCode.DELETE,
      NativeKeyEvent.VC_HOME -> KeyCode.HOME,
      NativeKeyEvent.VC_END -> KeyCode.END,
      NativeKeyEvent.VC_PAGE_UP -> KeyCode.PAGE_UP,
      NativeKeyEvent.VC_PAGE_DOWN -> KeyCode.PAGE_DOWN,
      NativeKeyEvent.VC_UP -> KeyCode.UP,
      NativeKeyEvent.VC_LEFT -> KeyCode.LEFT,
      NativeKeyEvent.VC_CLEAR -> KeyCode.CLEAR,
      NativeKeyEvent.VC_RIGHT -> KeyCode.RIGHT,
      NativeKeyEvent.VC_DOWN -> KeyCode.DOWN,
      NativeKeyEvent.VC_NUM_LOCK -> KeyCode.NUM_LOCK,
      NativeKeyEvent.VC_SEPARATOR -> KeyCode.SEPARATOR,
      NativeKeyEvent.VC_SHIFT -> KeyCode.SHIFT,
      NativeKeyEvent.VC_CONTROL -> KeyCode.CONTROL,
      NativeKeyEvent.VC_ALT -> KeyCode.ALT,
      NativeKeyEvent.VC_META -> KeyCode.META,
      NativeKeyEvent.VC_CONTEXT_MENU -> KeyCode.CONTEXT_MENU,
      NativeKeyEvent.VC_POWER -> KeyCode.POWER,
      NativeKeyEvent.VC_MEDIA_PLAY -> KeyCode.PLAY,
      NativeKeyEvent.VC_MEDIA_STOP -> KeyCode.STOP,
      NativeKeyEvent.VC_MEDIA_EJECT -> KeyCode.EJECT_TOGGLE,
      NativeKeyEvent.VC_VOLUME_MUTE -> KeyCode.MUTE,
      NativeKeyEvent.VC_VOLUME_UP -> KeyCode.UP,
      NativeKeyEvent.VC_VOLUME_DOWN -> KeyCode.DOWN,
      NativeKeyEvent.VC_KATAKANA -> KeyCode.KATAKANA,
      NativeKeyEvent.VC_UNDERSCORE -> KeyCode.UNDERSCORE,
      NativeKeyEvent.VC_KANJI -> KeyCode.KANJI,
      NativeKeyEvent.VC_HIRAGANA -> KeyCode.HIRAGANA,
      NativeKeyEvent.VC_SUN_HELP -> KeyCode.HELP,
      NativeKeyEvent.VC_SUN_STOP -> KeyCode.STOP,
      NativeKeyEvent.VC_SUN_FIND -> KeyCode.FIND,
      NativeKeyEvent.VC_SUN_AGAIN -> KeyCode.AGAIN,
      NativeKeyEvent.VC_SUN_UNDO -> KeyCode.UNDO,
      NativeKeyEvent.VC_SUN_COPY -> KeyCode.COPY,
      NativeKeyEvent.VC_SUN_INSERT -> KeyCode.INSERT,
      NativeKeyEvent.VC_SUN_CUT -> KeyCode.CUT
    ).withDefaultValue(KeyCode.UNDEFINED)

DPachs avatar Aug 25 '22 18:08 DPachs

Thx, that's very useful. Here it is in Kotlin:

mapOf(
         NativeKeyEvent.VC_ESCAPE to KeyCode.ESCAPE,
         NativeKeyEvent.VC_F1 to KeyCode.F1,
         NativeKeyEvent.VC_F2 to KeyCode.F2,
         NativeKeyEvent.VC_F3 to KeyCode.F3,
         NativeKeyEvent.VC_F4 to KeyCode.F4,
         NativeKeyEvent.VC_F5 to KeyCode.F5,
         NativeKeyEvent.VC_F6 to KeyCode.F6,
         NativeKeyEvent.VC_F7 to KeyCode.F7,
         NativeKeyEvent.VC_F8 to KeyCode.F8,
         NativeKeyEvent.VC_F9 to KeyCode.F9,
         NativeKeyEvent.VC_F10 to KeyCode.F10,
         NativeKeyEvent.VC_F11 to KeyCode.F11,
         NativeKeyEvent.VC_F12 to KeyCode.F12,
         NativeKeyEvent.VC_F13 to KeyCode.F13,
         NativeKeyEvent.VC_F14 to KeyCode.F14,
         NativeKeyEvent.VC_F15 to KeyCode.F15,
         NativeKeyEvent.VC_F16 to KeyCode.F16,
         NativeKeyEvent.VC_F17 to KeyCode.F17,
         NativeKeyEvent.VC_F18 to KeyCode.F18,
         NativeKeyEvent.VC_F19 to KeyCode.F19,
         NativeKeyEvent.VC_F20 to KeyCode.F20,
         NativeKeyEvent.VC_F21 to KeyCode.F21,
         NativeKeyEvent.VC_F22 to KeyCode.F22,
         NativeKeyEvent.VC_F23 to KeyCode.F23,
         NativeKeyEvent.VC_F24 to KeyCode.F24,
         NativeKeyEvent.VC_BACKQUOTE to KeyCode.BACK_QUOTE,
         NativeKeyEvent.VC_1 to KeyCode.DIGIT1,
         NativeKeyEvent.VC_2 to KeyCode.DIGIT2,
         NativeKeyEvent.VC_3 to KeyCode.DIGIT3,
         NativeKeyEvent.VC_4 to KeyCode.DIGIT4,
         NativeKeyEvent.VC_5 to KeyCode.DIGIT5,
         NativeKeyEvent.VC_6 to KeyCode.DIGIT6,
         NativeKeyEvent.VC_7 to KeyCode.DIGIT7,
         NativeKeyEvent.VC_8 to KeyCode.DIGIT8,
         NativeKeyEvent.VC_9 to KeyCode.DIGIT9,
         NativeKeyEvent.VC_0 to KeyCode.DIGIT0,
         NativeKeyEvent.VC_MINUS to KeyCode.MINUS,
         NativeKeyEvent.VC_EQUALS to KeyCode.EQUALS,
         NativeKeyEvent.VC_BACKSPACE to KeyCode.BACK_SPACE,
         NativeKeyEvent.VC_TAB to KeyCode.TAB,
         NativeKeyEvent.VC_CAPS_LOCK to KeyCode.CAPS,
         NativeKeyEvent.VC_A to KeyCode.A,
         NativeKeyEvent.VC_B to KeyCode.B,
         NativeKeyEvent.VC_C to KeyCode.C,
         NativeKeyEvent.VC_D to KeyCode.D,
         NativeKeyEvent.VC_E to KeyCode.E,
         NativeKeyEvent.VC_F to KeyCode.F,
         NativeKeyEvent.VC_G to KeyCode.G,
         NativeKeyEvent.VC_H to KeyCode.H,
         NativeKeyEvent.VC_I to KeyCode.I,
         NativeKeyEvent.VC_J to KeyCode.J,
         NativeKeyEvent.VC_K to KeyCode.K,
         NativeKeyEvent.VC_L to KeyCode.L,
         NativeKeyEvent.VC_M to KeyCode.M,
         NativeKeyEvent.VC_N to KeyCode.N,
         NativeKeyEvent.VC_O to KeyCode.O,
         NativeKeyEvent.VC_P to KeyCode.P,
         NativeKeyEvent.VC_Q to KeyCode.Q,
         NativeKeyEvent.VC_R to KeyCode.R,
         NativeKeyEvent.VC_S to KeyCode.S,
         NativeKeyEvent.VC_T to KeyCode.T,
         NativeKeyEvent.VC_U to KeyCode.U,
         NativeKeyEvent.VC_V to KeyCode.V,
         NativeKeyEvent.VC_W to KeyCode.W,
         NativeKeyEvent.VC_X to KeyCode.X,
         NativeKeyEvent.VC_Y to KeyCode.Y,
         NativeKeyEvent.VC_Z to KeyCode.Z,
         NativeKeyEvent.VC_OPEN_BRACKET to KeyCode.OPEN_BRACKET,
         NativeKeyEvent.VC_CLOSE_BRACKET to KeyCode.CLOSE_BRACKET,
         NativeKeyEvent.VC_BACK_SLASH to KeyCode.BACK_SLASH,
         NativeKeyEvent.VC_SEMICOLON to KeyCode.SEMICOLON,
         NativeKeyEvent.VC_QUOTE to KeyCode.QUOTE,
         NativeKeyEvent.VC_ENTER to KeyCode.ENTER,
         NativeKeyEvent.VC_COMMA to KeyCode.COMMA,
         NativeKeyEvent.VC_PERIOD to KeyCode.PERIOD,
         NativeKeyEvent.VC_SLASH to KeyCode.SLASH,
         NativeKeyEvent.VC_SPACE to KeyCode.SPACE,
         NativeKeyEvent.VC_PRINTSCREEN to KeyCode.PRINTSCREEN,
         NativeKeyEvent.VC_SCROLL_LOCK to KeyCode.SCROLL_LOCK,
         NativeKeyEvent.VC_PAUSE to KeyCode.PAUSE,
         NativeKeyEvent.VC_INSERT to KeyCode.INSERT,
         NativeKeyEvent.VC_DELETE to KeyCode.DELETE,
         NativeKeyEvent.VC_HOME to KeyCode.HOME,
         NativeKeyEvent.VC_END to KeyCode.END,
         NativeKeyEvent.VC_PAGE_UP to KeyCode.PAGE_UP,
         NativeKeyEvent.VC_PAGE_DOWN to KeyCode.PAGE_DOWN,
         NativeKeyEvent.VC_UP to KeyCode.UP,
         NativeKeyEvent.VC_LEFT to KeyCode.LEFT,
         NativeKeyEvent.VC_CLEAR to KeyCode.CLEAR,
         NativeKeyEvent.VC_RIGHT to KeyCode.RIGHT,
         NativeKeyEvent.VC_DOWN to KeyCode.DOWN,
         NativeKeyEvent.VC_NUM_LOCK to KeyCode.NUM_LOCK,
         NativeKeyEvent.VC_SEPARATOR to KeyCode.SEPARATOR,
         NativeKeyEvent.VC_SHIFT to KeyCode.SHIFT,
         NativeKeyEvent.VC_CONTROL to KeyCode.CONTROL,
         NativeKeyEvent.VC_ALT to KeyCode.ALT,
         NativeKeyEvent.VC_META to KeyCode.META,
         NativeKeyEvent.VC_CONTEXT_MENU to KeyCode.CONTEXT_MENU,
         NativeKeyEvent.VC_POWER to KeyCode.POWER,
         NativeKeyEvent.VC_MEDIA_PLAY to KeyCode.PLAY,
         NativeKeyEvent.VC_MEDIA_STOP to KeyCode.STOP,
         NativeKeyEvent.VC_MEDIA_EJECT to KeyCode.EJECT_TOGGLE,
         NativeKeyEvent.VC_VOLUME_MUTE to KeyCode.MUTE,
         NativeKeyEvent.VC_VOLUME_UP to KeyCode.UP,
         NativeKeyEvent.VC_VOLUME_DOWN to KeyCode.DOWN,
         NativeKeyEvent.VC_KATAKANA to KeyCode.KATAKANA,
         NativeKeyEvent.VC_UNDERSCORE to KeyCode.UNDERSCORE,
         NativeKeyEvent.VC_KANJI to KeyCode.KANJI,
         NativeKeyEvent.VC_HIRAGANA to KeyCode.HIRAGANA,
         NativeKeyEvent.VC_SUN_HELP to KeyCode.HELP,
         NativeKeyEvent.VC_SUN_STOP to KeyCode.STOP,
         NativeKeyEvent.VC_SUN_FIND to KeyCode.FIND,
         NativeKeyEvent.VC_SUN_AGAIN to KeyCode.AGAIN,
         NativeKeyEvent.VC_SUN_UNDO to KeyCode.UNDO,
         NativeKeyEvent.VC_SUN_COPY to KeyCode.COPY,
         NativeKeyEvent.VC_SUN_INSERT to KeyCode.INSERT,
         NativeKeyEvent.VC_SUN_CUT to KeyCode.CUT
      )

sghpjuikit avatar Sep 02 '22 10:09 sghpjuikit