A "mouse button was just pressed" event

I’ve seen that recently there was a new event added called “key was just pressed”. This saved a lot of the headaches with making the game feel “snappy”. Before that you needed a trigger once and then an additional wait aciton if you didn’t want it returning true after it resets when a key was held down.

I’d personally like the same feature for mouse buttons and touch aswell

5 Likes

Why would you need a wait action? If the conditions are “key is pressed” and “trigger once while true”, then the event will only action once while the key is pressed. This is the method I use to run an action when the key press has just started. There is no need for a wait.

Key pressed, animation plays
Animation or the action finishes and returns back to the old animation
If you’re still holding the key, it plays again

Without just pressed you need to add a wait timer (i do .001 seconds for non-noticable delay) or just make the key press released instead (which adds “input delay”) Some mechanics just break if you don’t add that. For an example one of my games puzzles used this before the update because the animation would just get stuck if you held the key at the time the animation returned back to neutral.

It might not be needed on simple stuff but on advanced stuff does need it. My guess is that the engine itself does the said .001 wait command on the just pressed event along with the trigger once aswell. So it just saves you 2 lines of code.

Then your conditions are more than just “key is pressed” with a trigger once.

I just realised you originally asked for the “key was just pressed” feature but for mouse buttons and touch.

Can I ask that when you post a request, you put in what you are after first, and the explanation following it? It’ll saves people like me, too lazy to read the full post, from missing the actual guts of the request :face_with_diagonal_mouth:

The title is literally called a mouse button was just pressed event : D

1 Like

I still don’t understand. A was pressed would be the same as a pressed with a triggered once.

A bit of context. It could be the other conditions that are resetting the trigger once. Otherwise, you might need to use a boolean variable to track a state.

Let’s say you used

Mouse is pressed
Cursor is on an object
Trigger once

The trigger once would be reset or removed when either condition went from false to true and the back to false.

In this example, you could add a boolean state or move the trigger once so it’s directly below the mouse condition.

Mouse is pressed
Trigger once
Cursor is on an object

This isn’t the same. The trigger once wouldn’t be removed if the cursor was no longer on the object.

Can you give an example of a scenario?

Key is jest pressed
Works like

Key pressed
Trigger once

But apparently trigger once is not perfect
So we get key JUST pressed

And now we have
Key pressed
Key released
Key JUST pressed

Would only make perfect sense to have now
Mouse button pressed
Mouse button released
Mouse button JUST pressed

JUST happens in that exact moment
Same as released same as at beginning of the scene
They can happen only once

Like you cannot constantly release key you just release it once then you need to press it to release it again

Same with just pressed
You can press and hold it
But actual pressing happens only once

Same as like piano key
You can press it but sound will go from it only once you need to release and press it again to get sound again

1 Like

All I want is to eliminate the trigger once just like what has happened recently for key just pressed, so that we can just have mouse pressed, cursor on object. In fact, if I had made the request, I would have said can we have an action that is mouse is clicked on object. Just one beautiful action instead of three. I didn’t try to understand the OP’s wait stuff.

Zero, I don’t understand whether you are for or against the idea. As for

I have found that even though key released should be an inbuilt once event, a trigger once is needed.

But if anyone says the actions list is getting too clogged with pressed, just pressed, and all the others, I’d agree with that too. But I just get tired of adding trigger once so often :upside_down_face:

I assume that means you support it. So far I’m the only person to have given the request a heart. I assume the devs notice things like that if they’re prioritising things.

I have no idea how you could get anything else from my words

I am always in for unifying stuff
Why we have Random()
But we have round() not Round()
Or mod() not Mod()

90% of expressions as 1st word capital
WTF

Anyway maybe to be more precise i am always IN for any change that will leave less room for confusing users
Having same set of conditions for mouse buttons as for keyboard would just make perfect sense

Also i think we should vote for different names

For example it should not be key pressed and key JUST pressed and

It should be
Key Held (or Key Down)
Key Released
Key Just Pressed (or Key pressed)

BUT 1st should indicate holding it down
Same as we have in button states clicked and pressed

Clicked means released
Pressed means is being held
This would be perfect moment if adding something to unify names
And we only need to remember 1 rule for
Objects / keys / buttons
Instead of each of them have different set of names

There’s also scope for a ‘Key About To Be Pressed’ …er possibly.
‘the cursor/touch is on an object and index finger moving’

How
Key About To Be Pressed
Would work?

We are talking about conditions which would trigger something
And in my eyes you just described Key Not Pressed
Or INVERTED Key Pressed

As with touch you are checking if something or is not on object

sorry - i’m just mucking about! - I couldn’t resist it.
i gave the post a heart!
hector-hector-salamanca

i’m a bummer as the pic

so i’m gonna stick with the old method…

also understanding how trigger once works is mandatory to learn how to dev in GD.
Triggeronce is mainly used in keypress events; doing without it means learning late. just keypressed should be used by those who know what they’re doing.

And now that is exactly why i would say let’s change names to

Key HELD
Key PRESSED
or
Key JUST PRESSED

Where pressed/just pressed
Would be same as in with trigger once when it comes to functionality

BUT that naming would teach ppl that if you are checking if key is held you are doing something as long as its held
When if you would use pressed (i think now JUST pressed makes more sense) is something that happens only once

1 Like

What @ZeroX4 Said basically. Key just pressed only returns the event once but pressed with trigger once can return again. You also have to add a wait command in-between actions sometimes for it to work. Check one of my older replies above with how i’ve used a wait event before key was just pressed was added :

It just makes stuff easier and less messy. Not to mention quite bit of the newer people on the engine doesn’t really know about the wait command itself aswell so it makes it easier for the beginners too