How do I detect LEFT SHIFT/ RIGHT SHIFT?

Get help using Construct 2

Post » Fri Jun 06, 2014 10:19 pm

Working on a pinball game.
The keyboard object in C2 only recognizes "Shift", not left/right shift. Left/right shift or left/right Ctrl are kinda necessary for a pinball game.

Is this hard coded? Anyone know of a fix?

This here says Left and Right shift keys are distinguishable.

http://stackoverflow.com/questions/2297 ... up-in-chro

@Ashley Is there any way to make the keyboard object accept location?
Last edited by christina on Fri Jun 06, 2014 10:46 pm, edited 3 times in total.
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Fri Jun 06, 2014 10:32 pm

@Kyatric have you seen this issue crop up before? Any advice?
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Sat Jun 07, 2014 12:38 am

From a quick test, all I can say is that left and right shift share the same keycode, so apparently no way to differentiate them.
My advice would be to use shift and perhaps control, or different keys to control each side of the flipper.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,332
Reputation: 71,306

Post » Sat Jun 07, 2014 9:44 am

@Kyatric thank you for the quick reply.

This test here proves that, yes, keycode is 16 for both SHIFT keys, but Javascript *can* handle location via the constant DOM_KEY_LOCATION_ which can be "standard", "left", "right" or "numpad".

http://jsfiddle.net/ySkn8/1/

It's a javascript question, if only I knew how to modify the keyboard plugin to add this functionality:

( window.onkeydown = function(event)
{
var o = 'event = onkeydown, which = ' + event.which + ', location = ';

switch(event.location)
{
case KeyboardEvent.DOM_KEY_LOCATION_STANDARD: o += 'standard'; break;

case KeyboardEvent.DOM_KEY_LOCATION_NUMPAD: o += 'numpad'; break;

case KeyboardEvent.DOM_KEY_LOCATION_LEFT: o += 'left'; break;

case KeyboardEvent.DOM_KEY_LOCATION_RIGHT: o += 'right'; break;
}

)

I've built the game around "A" and "right cursor key" but my testers are complaining about accessibility.
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Sat Jun 07, 2014 9:57 am

Why not allow the player to map their own keys then they can use whats comfortable for them.
B
51
S
16
G
9
Posts: 1,098
Reputation: 11,252

Post » Sat Jun 07, 2014 9:59 am

@spongehammer: that's the complaint. They all want to map left/right SHIFT or some other distinct Key like Left/Right CTRL. Ctrl+Shift or other combinations of keys aren't comfortable enough apparently.
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Fri Jun 13, 2014 11:15 am

bump: @Ashley any ideas? Adding the code to the Keyboard Plugin should be trivial, no? Should I file a request?
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Post » Fri Jun 13, 2014 12:19 pm

I'm with you in that, for me, pinball flippers are best using both SHIFT keys, so I say go ahead and post an 'official' request.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,555
Reputation: 60,454

Post » Fri Jun 13, 2014 12:22 pm

I'll have a look at implementing this for the next beta (note we're due a stable release next and I don't usually add new features in stable updates).
Scirra Founder
B
403
S
238
G
89
Posts: 24,648
Reputation: 196,133

Post » Fri Jun 13, 2014 12:26 pm

You're incredible, tx @Ashley.

Big disclaimer: Chrome apparently only correctly registers DOM_KEY_LOCATION on key down. Key down on left shift would return "Left", but key up on left Shift would return "standard".
B
28
S
12
G
4
Posts: 193
Reputation: 4,581

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests