Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling system key mappings for imgui.is_key_down() #190

Closed
bgribble opened this issue Mar 16, 2024 · 1 comment
Closed

Handling system key mappings for imgui.is_key_down() #190

bgribble opened this issue Mar 16, 2024 · 1 comment

Comments

@bgribble
Copy link

bgribble commented Mar 16, 2024

Hi, I'm moving an app that was originally written in Gtk/Clutter in Python to Dear ImGui. I started with pyimgui but I really need to use implot and a nodes-and-links package such as imnodes or imgui_node_editor so imgui_bundle seems just right.

My app does a lot of keyboard handling for custom mappings of all kinds of key combos so I am using this basic approach (pulled from a suggestion by ocornut) to find out all the keys that are down:

def keys_down():
    keys = []
    for index in range(512, int(imgui.Key.count)):
        key_down = imgui.is_key_down(imgui.Key(index))
        if key_down:
            keys.append(imgui.Key(index))
    return set(keys)

This mostly works, but only give me the keys whose scancodes are pressed down -- i.e. I have shift lock and control swapped at the window manager level, and when I press the key that's marked "Caps lock" on my keyboard I get imgui.Key.caps_lock even though that's actually the control key for me.

Is there a layer of representation I can access that has the keys as other windows see them, rather than just the scan codes?

@pthom
Copy link
Owner

pthom commented Mar 16, 2024

Hello,

This issue is more related to Dear ImGui in itself. May be you should have a look at this issue which summarizes recent changes in the keyboard api, as well as the other issues related to keyboard mapping within ImGui.

@pthom pthom closed this as completed Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants