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.

[1.8] [Resolved] perform event on MouseClick only when Control key down

Featured Replies

Posted

What is the way to handle doing something on a  MouseClick but only if a control key is pressed at the time ?

 

I can register a keybinding and get that to work, and I can get a click event to work, but since they are separate events, how do you combine them into one ?

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

  • Author

Thanks !

 

I was looking at tutorials and they all had parts of what I needed but then again it seems things changed in 1.7 so I was a bit confused and some of the tutorials are for an earlier version....

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

The reason you would use KeyInputEvent is if you want the actual key press to trigger something directly, e.g. press 'x' to open a GUI.

 

If your key binding is used elsewhere, such as in combination with a mouse click, then as diesieben said, you don't need KeyInputEvent for that particular case.

 

Furthermore, if you don't care about users being able to change the key used, you can get away without a KeyBinding at all and just use the Keyboard object directly to check key states. This is what happens in GUIs (indirectly), for example, when the Escape key is pressed.

The reason you would use KeyInputEvent is if you want the actual key press to trigger something directly, e.g. press 'x' to open a GUI.

Nope, no need to.

In that case you would use ClientTickEvent (which actually fires more rarely than KeyInputEvent most of the time) and check for your key being pressed there.

My understanding is that KeyInputEvent fires immediately when a key is pressed, whereas ClientTickEvent you'd not only be waiting to process the input (granted probably an imperceptible amount of time), but you'd be taking a craps shoot as the key might not still be pressed if the player simply tapped it very quickly (very unlikely, but still), depending on whether you check if the key is still down or if the pressed variable was incremented and has yet to be decremented.

 

Plus, semantically, it makes more sense to use the KeyInputEvent, though subscribing to it may waste some resources by processing for every single key when one only actually cares about a few.

 

Am I completely off base here, i.e. is that not how it works? If your situation is very dependent on the timely processing of the key press, e.g. combat / movement related, wouldn't you want KeyInputEvent?

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.