Posted January 13, 201411 yr My apologies if I am missing something very obvious. It may be that this area has not yet been fully coded for the 1.7.2 forge, in which case I understand. I am trying to update a couple of mods which I had working in 1.6. They used a keyhandler so that I could detect various function key presses to make things appear and disappear on-screen. I realise that the keyhandler has been entirely replaced by an event-driven approach in 1.7. I believe we now have InputEvent which implements Event, and KeyInputEvent and MouseInputEvent which implement InputEvent. I can see that KeyInputEvent does indeed fire when a key is pressed, as expected. However, I am lost when trying to discover which key has been pressed! There is no code within KeyInputEvent, so I have no public getter methods or public variables that I can access. As I said, maybe I am simply trying to use something that hasn't yet been implemented, in which case I apologise for wasting anyone's time.
January 13, 201411 yr In your keyhandler class you need to register your keys. Like: private KeyBinding key_openGUI = new KeyBinding("key name", Keyboard.KEY_F, "My_Mod_Category"); public static openGUI; public KeyHandlerClass() { ClientRegistry.registerKeyBinding(key_openGUI); } Then under KeyInputEvent you can check if the key has been pressed. @SubscribeEvent public void tick(KeyInputEvent event) { this.openGUI = false; if(key_openGUI.func_151468_f()) { this.openGUI = true; } } This is just an example so it might not actually work 100%
January 13, 201411 yr Author Thank you so much, Skerp! I was doing all of the registration already. That was fine. But you've shown me the method to detect the key-presses and that works perfectly I'll be able to put my mods up very soon - probably today. Brilliant news, and thank you again
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.