skeldoor / hold-your-ground

Runelite Plugin to stop your character moving to attack an NPC
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

HYH Hotkey blocks keypress to client #4

Open daltonpearson opened 4 months ago

daltonpearson commented 4 months ago

So I use esc as my HYH hotkey since I already have it bound to one of my extra mouse buttons in order to exit out of the bank/menus. The only problem is that when I use esc it doesn't get sent through to client. The same thing happens if I was to use another key which also blocks that key when typing in chat. My expectation would be that the bound key would still get sent through to the client even when activating/deactivating HYH via the hotkey.

Thanks for all the work you've done already!

daltonpearson commented 4 months ago

looks like this isn't really your issue but I doubt we'd get a bug fix/flag added in the client api. Overriding the keyPressed method to not consume non-modifier keys should sort that out I think. I'll leave it up to you whether or not to use this strategy. https://github.com/skeldoor/hold-your-ground/blob/1d3bb448eb9d0e1e2a333aba3f61129cd18c33d8/src/main/java/com/skeldoor/HoldYourGroundPlugin.java#L60

    private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.holdMovingHotkey())
    {

        @Override
        public void keyPressed(KeyEvent e)
        {
            if (keybind.get().matches(e))
            {
                boolean wasPressed = isPressed;
                isPressed = true;
                if (!wasPressed)
                {
                    hotkeyPressed();
                }
            }
        }

        @Override
        public void hotkeyPressed()
        {
            overrideHoldMove = true;
        }

        @Override
        public void hotkeyReleased()
        {
            overrideHoldMove = false;
        }
    };