[bge.events.LEFTMOUSE] doesn't work

Why does this not work…

import bge
import random
from bge import logic
cont = logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
keyboard = bge.logic.keyboard

JUST_RELEASED= bge.logic.KX_INPUT_JUST_RELEASED

if keyboard.events[bge.events.LEFTMOUSE] == JUST_RELEASED:
    cont.activate("sound")

But this does?

import bge
import random
from bge import logic
cont = logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
keyboard = bge.logic.keyboard

JUST_RELEASED= bge.logic.KX_INPUT_JUST_RELEASED

if keyboard.events[bge.events.YKEY] == JUST_RELEASED:
    cont.activate("sound")

The only thing that changed was LEFTMOUSE became YKEY, and the doccumentation https://docs.blender.org/api/blender_python_api_2_77_0/bge.events.html#bge.events.LEFTMOUSE clearly states I’m using the correct phrase.

I believe it’s because you’re using bge.logic.keyboard instead of bge.logic.mouse
Also, events is deprecated - inputs is recommended now

What you want is probably this:

if bge.logic.mouse.inputs[bge.events.LEFTMOUSE].released:
    do this...

Thanks for your response.
I have never heard of inputs. How do I import inputs? Is it a part of bge?

Currently I get a object has no attribute "inputs" error.
I can’t just say, from bge import logic, inputs apparently.

Hmm, are you using an old version of the game engine sorry?

Maybe try this:

if bge.logic.mouse.events[bge.events.LEFTMOUSE] == bge.logic.KX_INPUT_JUST_RELEASED:
    Do something

I’m using 2.79, long before UPBGE. My PC crashes at anything designed after the stone age.

Your solution is the same thing I posted in my initial example.

I Defined JUST_RELEASED= bge.logic.KX_INPUT_JUST_RELEASED
Then called that with:

if keyboard.events[bge.events.LEFTMOUSE] == JUST_RELEASED:
    cont.activate("sound")

Notice, it works exactly as expected when I use the key phrase YKEY or SPACEKEY for Y or spacebar. It only happens when I try and call mouse keys.

I have a suspicion the phrases for mouse keys changed along the way somewhere.

Any thoughts?

Yes, your problem is that you’re using keyboard.events, not mouse.events

Try my solution, it should work

Ah… Good catch…
Thank you for your time and patience! I appreciate it.