runelite-client: Make hotkeys run on KeyPressed
Finding when keyUp actually happens is difficult because you have to store state to tell if a key is up on modifier or it's optional non-modifier. The current implementation is good enough for masking events, but not accurate enough for generating them Fixes #4513
This commit is contained in:
@@ -175,7 +175,7 @@ public class ScreenshotPlugin extends Plugin
|
|||||||
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey())
|
private final HotkeyListener hotkeyListener = new HotkeyListener(() -> config.hotkey())
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void hotkeyReleased()
|
public void hotkeyPressed()
|
||||||
{
|
{
|
||||||
takeScreenshot(format(new Date()));
|
takeScreenshot(format(new Date()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ package net.runelite.client.util;
|
|||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.runelite.client.config.Keybind;
|
import net.runelite.client.config.Keybind;
|
||||||
import net.runelite.client.input.KeyListener;
|
import net.runelite.client.input.KeyListener;
|
||||||
@@ -36,7 +35,6 @@ public abstract class HotkeyListener implements KeyListener
|
|||||||
{
|
{
|
||||||
private final Supplier<Keybind> keybind;
|
private final Supplier<Keybind> keybind;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private boolean isPressed = false;
|
private boolean isPressed = false;
|
||||||
|
|
||||||
private boolean isConsumingTyped = false;
|
private boolean isConsumingTyped = false;
|
||||||
@@ -77,7 +75,6 @@ public abstract class HotkeyListener implements KeyListener
|
|||||||
{
|
{
|
||||||
isPressed = false;
|
isPressed = false;
|
||||||
isConsumingTyped = false;
|
isConsumingTyped = false;
|
||||||
hotkeyReleased();
|
|
||||||
if (Keybind.getModifierForKeyCode(e.getKeyCode()) == null)
|
if (Keybind.getModifierForKeyCode(e.getKeyCode()) == null)
|
||||||
{
|
{
|
||||||
// Only consume non modifier keys
|
// Only consume non modifier keys
|
||||||
@@ -89,8 +86,4 @@ public abstract class HotkeyListener implements KeyListener
|
|||||||
public void hotkeyPressed()
|
public void hotkeyPressed()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hotkeyReleased()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user