mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 07:17:27 +00:00
Made CTRL, Shift, ALT, and Meta keys execute the keyPressed event when pressed down, not just when released.
This commit is contained in:
1 parent
b309738c0b
commit
8db16459df
1 file changed
+13
-23
@@ -64,33 +64,23 @@ public class ClientTickHandler{
|
||||
}
|
||||
|
||||
int key = Keyboard.getEventKey();
|
||||
long time = Keyboard.getEventNanoseconds();
|
||||
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
|
||||
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||
boolean keyDown = Keyboard.isKeyDown(key);
|
||||
|
||||
if(Keyboard.getEventKeyState()) {
|
||||
if(!this.isIgnoredKey(key)) {
|
||||
this.buttonTime = time;
|
||||
StringBuilder keysDownString = new StringBuilder();
|
||||
for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys
|
||||
if(Keyboard.isKeyDown(i)){
|
||||
keysDownString.append(Integer.valueOf(i)).append(",");
|
||||
}
|
||||
}
|
||||
|
||||
if(time-this.buttonTime == 0 || !Keyboard.getEventKeyState()) {
|
||||
boolean isCtrlPressed = Keyboard.isKeyDown(157) || Keyboard.isKeyDown(29);
|
||||
boolean isShiftPressed = Keyboard.isKeyDown(54) || Keyboard.isKeyDown(42);
|
||||
boolean isAltPressed = Keyboard.isKeyDown(184) || Keyboard.isKeyDown(56);
|
||||
boolean isMetaPressed = Keyboard.isKeyDown(220) || Keyboard.isKeyDown(219);
|
||||
boolean keyDown = Keyboard.isKeyDown(key);
|
||||
|
||||
StringBuilder keysDownString = new StringBuilder();
|
||||
for(int i = 0; i < Keyboard.getKeyCount(); i++){//Creates a comma separated string of the integer IDs of held keys
|
||||
if(Keyboard.isKeyDown(i)){
|
||||
keysDownString.append(Integer.valueOf(i)).append(",");
|
||||
}
|
||||
}
|
||||
if(keysDownString.length() > 0){//Removes last comma for later parsing
|
||||
keysDownString.deleteCharAt(keysDownString.length()-1);
|
||||
}
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()});
|
||||
if(keysDownString.length() > 0){//Removes last comma for later parsing
|
||||
keysDownString.deleteCharAt(keysDownString.length()-1);
|
||||
}
|
||||
|
||||
NoppesUtilPlayer.sendData(EnumPlayerPacket.KeyPressed, new Object[]{Integer.valueOf(key), Boolean.valueOf(isCtrlPressed), Boolean.valueOf(isShiftPressed), Boolean.valueOf(isAltPressed), Boolean.valueOf(isMetaPressed), Boolean.valueOf(keyDown), keysDownString.toString()});
|
||||
}
|
||||
|
||||
private boolean isIgnoredKey(int key) {
|
||||
|
||||
Reference in new issue
Block a user