KeyMapping: Add additional key remapping (#2075)

KeyMapping: Add additional key remapping
This commit is contained in:
Owain van Brakel
2019-12-06 00:18:37 +01:00
committed by GitHub
3 changed files with 69 additions and 0 deletions

View File

@@ -252,4 +252,37 @@ public interface KeyRemappingConfig extends Config
{
return new ModifierlessKeybind(KeyEvent.VK_ESCAPE, 0);
}
@ConfigItem(
position = 20,
keyName = "ctrl",
name = "CTRL",
description = "The key which will replace {CTRL}."
)
default ModifierlessKeybind ctrl()
{
return new ModifierlessKeybind(KeyEvent.VK_CONTROL, 0);
}
@ConfigItem(
position = 21,
keyName = "alt",
name = "ALT",
description = "The key which will replace {ALT}."
)
default ModifierlessKeybind alt()
{
return new ModifierlessKeybind(KeyEvent.VK_ALT, 0);
}
@ConfigItem(
position = 22,
keyName = "shift",
name = "SHIFT",
description = "The key which will replace {SHIFT}."
)
default ModifierlessKeybind shift()
{
return new ModifierlessKeybind(KeyEvent.VK_SHIFT, 0);
}
}

View File

@@ -162,6 +162,21 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener
modified.put(e.getKeyCode(), KeyEvent.VK_ESCAPE);
e.setKeyCode(KeyEvent.VK_ESCAPE);
}
else if (plugin.getCtrl().matches(e))
{
modified.put(e.getKeyCode(), KeyEvent.VK_CONTROL);
e.setKeyCode(KeyEvent.VK_CONTROL);
}
else if (plugin.getAlt().matches(e))
{
modified.put(e.getKeyCode(), KeyEvent.VK_ALT);
e.setKeyCode(KeyEvent.VK_ALT);
}
else if (plugin.getShift().matches(e))
{
modified.put(e.getKeyCode(), KeyEvent.VK_SHIFT);
e.setKeyCode(KeyEvent.VK_SHIFT);
}
}
switch (e.getKeyCode())
@@ -293,6 +308,18 @@ class KeyRemappingListener extends MouseAdapter implements KeyListener
{
e.setKeyCode(KeyEvent.VK_ESCAPE);
}
else if (plugin.getCtrl().matches(e))
{
e.setKeyCode(KeyEvent.VK_CONTROL);
}
else if (plugin.getAlt().matches(e))
{
e.setKeyCode(KeyEvent.VK_ALT);
}
else if (plugin.getShift().matches(e))
{
e.setKeyCode(KeyEvent.VK_SHIFT);
}
}
}
else

View File

@@ -122,6 +122,12 @@ public class KeyRemappingPlugin extends Plugin
private ModifierlessKeybind f12;
@Getter(AccessLevel.PACKAGE)
private ModifierlessKeybind esc;
@Getter(AccessLevel.PACKAGE)
private ModifierlessKeybind ctrl;
@Getter(AccessLevel.PACKAGE)
private ModifierlessKeybind alt;
@Getter(AccessLevel.PACKAGE)
private ModifierlessKeybind shift;
@Override
protected void startUp()
@@ -299,5 +305,8 @@ public class KeyRemappingPlugin extends Plugin
this.f11 = config.f11();
this.f12 = config.f12();
this.esc = config.esc();
this.ctrl = config.ctrl();
this.alt = config.alt();
this.shift = config.shift();
}
}