Thread: Using GTK3.0 numpad keys

  1. #1
    Registered User
    Join Date
    Feb 2024
    Posts
    3

    Using GTK3.0 numpad keys

    I'm using GTK3.0 and trying to make the 5 key on the num pad respond when numlock is off. Is there any way to see if numlock is off and still have that key respond? This is how I have it set up.

    In my int main I call
    g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);
    it works for all the other keys.

    Then in my keypress function I use a switch like so.
    switch (event->keyval)
    {
    case GDK_KEY_Up:

    Another way I could kame this work is if there is a name for
    the 5 key on the numpad when numlock is off, in the same way that
    8 is GTK_KEY_Up when numlock is off.

    Is there a name for the 5 when numlock is off?
    Also is there a way to tell the difference in GTK3.0 between
    the numbers above the letters and the ones in the numpad?

    If not, is there another way I could use the 5 key on numpad
    with numlock off? Like maybe set it up to listen for it, but
    not through GTK? I don't know how I would do that, since I use
    GTK for my GUI. Any help is much appreciated.


  2. #2
    Registered User
    Join Date
    Apr 2021
    Posts
    140
    I found a gtk header file online that contains keysym definitions. I believe that 0xffb5 is KP_5. There are, of course, KP_0 through KP_9 definitions.

    However, as you point out there are plenty of computer keyboards where the NumLock engages keypad-as-numbers, but without NumLock the keypad is mapped to directional movement keys. (up, left, page-down, etc.) In that case, the meaning assigned to keypad 5 can vary from dot ('.') to nothing.

    I believe you should make a point of writing a utility program, or adding a logging mode to your existing program, so that you can print out the keypress event structures (like how the xev program does) and see what is being sent with various combinations of numlock and different keyboards, if you are able to use different keyboards.

  3. #3
    Registered User
    Join Date
    Feb 2024
    Posts
    3
    I know the keyboard sends a signal even when the numlock is off, I used one of those keyboard testing websites. I just don't know what the actual signal sent is when numlock is off, or if gtk can catch it.

  4. #4
    Registered User
    Join Date
    Dec 2017
    Posts
    1,633
    Try one of these:
    Code:
    0x00ff58 Begin
    0x00ff9d KP_Begin
    It's from the list here: https://github.com/linuxmint/gtk/blo...k/keynames.txt
    Here is the section with the above codes in it:
    Code:
    0x00ff50 Home
    0x00ff51 Left
    0x00ff52 Up
    0x00ff53 Right
    0x00ff54 Down
    0x00ff55 Page_Up
    0x00ff55 Prior
    0x00ff56 Page_Down
    0x00ff56 Next
    0x00ff57 End
    0x00ff58 Begin
    0x00ff60 Select
    0x00ff61 Print
    0x00ff62 Execute
    0x00ff63 Insert
    0x00ff65 Undo
    0x00ff66 Redo
    0x00ff67 Menu
    0x00ff68 Find
    0x00ff69 Cancel
    0x00ff6a Help
    0x00ff6b Break
    0x00ff7e Arabic_switch
    0x00ff7e Greek_switch
    0x00ff7e Hangul_switch
    0x00ff7e Hebrew_switch
    0x00ff7e ISO_Group_Shift
    0x00ff7e kana_switch
    0x00ff7e Mode_switch
    0x00ff7e script_switch
    0x00ff7f Num_Lock
    0x00ff80 KP_Space
    0x00ff89 KP_Tab
    0x00ff8d KP_Enter
    0x00ff91 KP_F1
    0x00ff92 KP_F2
    0x00ff93 KP_F3
    0x00ff94 KP_F4
    0x00ff95 KP_Home
    0x00ff96 KP_Left
    0x00ff97 KP_Up
    0x00ff98 KP_Right
    0x00ff99 KP_Down
    0x00ff9a KP_Page_Up
    0x00ff9a KP_Prior
    0x00ff9b KP_Next
    0x00ff9b KP_Page_Down
    0x00ff9c KP_End
    0x00ff9d KP_Begin
    0x00ff9e KP_Insert
    0x00ff9f KP_Delete
    0x00ffaa KP_Multiply
    0x00ffab KP_Add
    0x00ffac KP_Separator
    0x00ffad KP_Subtract
    0x00ffae KP_Decimal
    0x00ffaf KP_Divide
    0x00ffb0 KP_0
    0x00ffb1 KP_1
    0x00ffb2 KP_2
    0x00ffb3 KP_3
    0x00ffb4 KP_4
    0x00ffb5 KP_5
    0x00ffb6 KP_6
    0x00ffb7 KP_7
    0x00ffb8 KP_8
    0x00ffb9 KP_9
    0x00ffbd KP_Equal
    Maybe one of the following instead of "begin":
    Code:
    0x00ff80 KP_Space
    0x00ff89 KP_Tab
    0x00ff8d KP_Enter
    You could of course press the key and print the keycode.
    Last edited by john.c; 02-20-2024 at 12:05 PM.
    A little inaccuracy saves tons of explanation. - H.H. Munro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Gtk3+Glade installation and tutorials
    By Wido in forum Tech Board
    Replies: 1
    Last Post: 09-24-2018, 11:40 PM
  2. anyone know anything about GTK2 to GTK3?
    By userxbw in forum C Programming
    Replies: 3
    Last Post: 10-15-2017, 06:26 AM
  3. Which toolkit should I use: gtk2+ or gtk3+?
    By hikerFreak in forum General Discussions
    Replies: 2
    Last Post: 12-10-2016, 02:59 AM
  4. I need help with GTK3 treeviews, and paneviews
    By KoRn KloWn in forum C Programming
    Replies: 6
    Last Post: 01-18-2013, 01:31 PM
  5. numpad
    By dP munky in forum Game Programming
    Replies: 1
    Last Post: 11-14-2002, 01:09 AM

Tags for this Thread