shift and mouse1 not working?

I was trying to track a bug down in my game, it came down to this. When the shift (left in this example, but does not matter which) is held down, mouse1 events are not found? but when the a key is held down, they are…Am I doing something wrong?

import direct.directbase.DirectStart
from pandac.PandaModules import *

keymap = {'m1':0,'shift':0}

def setKey(key,val):
	keymap[key]=val
	print key,val



base.accept('mouse1',setKey,['m1',1])
base.accept('mouse1-up',setKey,['m1',0])

base.accept('a',setKey,['shift',1])
base.accept('lshift',setKey,['shift',1])
base.accept('lshift-up',setKey,['shift',0])
base.accept('a-up',setKey,['shift',0])

run()

Shift, control, and alt are known as modifier keys. To use these keys in conjunction with other keys, put these keys in front of the other key. For your case, it’s “shift-mouse1”. The order of these modifier keys is always shift-control-alt if you use some of them at once.

So if you need to accept mouse 1 with and without the shift modifier, you may accept both events to the same function (mouse1 and SHIFT+Mouse1)

What I wanted was for both to happen when both were pushed, and I found a workaround, but I still don’t understand why ctr,shift,alt should mask the other key’s events…maybe send the shift-mouse1 as well, but also send the mouse1,shift,and shiftl/shiftr events. Please find holes in my logic here :slight_smile:

Search the forums for “modifier” if it’s still foggy.
If you don’t want the modifier keys at all, read here :
discourse.panda3d.org/viewtopic.php?t=1313

to disable:

base.mouseWatcherNode.setModifierButtons(ModifierButtons())

Thanks, everyone. I think I understand now.

The above code no longer works. Instead, use:

base.buttonThrowers[0].node().setModifierButtons(ModifierButtons())

Howrad, it seems to work for me…why do you think that it doesn’t work?