Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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%

  • 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 :D

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.