Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Space key not read  (Read 1691 times)

0 Members and 1 Guest are viewing this topic.

s4weng

  • Newbie
  • *
  • Posts: 3
    • View Profile
Space key not read
« on: June 20, 2015, 06:37:43 am »
Hey all!

Rephrased issue:

If the sequence of keys being pressed (and held) is Up + Left + Space or Left + Up + Space; the Space key press isn't recorded.  If it's something like Up + Right + Space or Right + Down + Space it's fine.

Tested on my current project, and also the code used in the  "Game from Scratch: Pang in C++" tutorial.

(Original question:)
/* I'm getting a strange read on some of the input key events, as in when I press a key, it's seen as an event, then the release is seen as an event, but then there's one more event.  I implemented a keyToString function to output these keys.

/When I press A, I get A, F13, then A again. (0, 97)
B -> B, F14, B (1, 98)
C -> C, F15, C (2, 99)
D -> D, Pause, D (3, 100)
Return -> Return, N, Return (58, 13)

The numbers in the bracket are the enumerator indices related to the keys as specified by the documentations: http://www.sfml-dev.org/documentation/2.0/classsf_1_1Keyboard.php

I don't think all the keys do this, but these are some of the ones I tested out.

What I don't understand is, what does the event type does the middle key represent? */

Thanks in advance!
« Last Edit: June 20, 2015, 07:34:01 am by s4weng »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Strange Keyboard Relations?
« Reply #1 on: June 20, 2015, 07:08:54 am »
I barely understand what you mean.
When pressing and releasing a key it triggers 3 events: KeyPressed, KeyReleased and TextEntered. The unicode value of 'a' is 97. When using an event, be sure to check the event type before using its values.
« Last Edit: June 20, 2015, 07:12:05 am by G. »

s4weng

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Strange Keyboard Relations?
« Reply #2 on: June 20, 2015, 07:13:13 am »
I barely understand what you mean.
When pressing and releasing a key it triggers 3 events: KeyPressed, KeyReleased and TextEntered. The unicode value of 'a' is 97. When using an event, be sure to check the event type before using its values.

Sorry, even as I typed it I barely knew what I was saying.  Your post answered my question though, so thank you!

Edit - Rephrased my issue...I think it's a bit clearer now.
« Last Edit: June 20, 2015, 07:22:27 am by s4weng »

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Space key not read
« Reply #3 on: June 20, 2015, 10:49:23 am »
That's the way keyboards are made. Your problem is called keyboard ghosting.
"Ghosting" is the problem that some keyboard keys don't work when multiple keys are pressed simultaneously. The key presses that don't show up on the computer or seem to have disappeared are said to have been "ghosted". On most keyboards, even some that are explicitly marketed as "Anti-Ghosting," this happens with many three key combinations. Imagine playing your favorite video game and not being able to, say, run diagonally and fire your weapon at the same time (say pressing a, w, and g simultaneously). This is a result of the internal design of most existing keyboards

s4weng

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Space key not read
« Reply #4 on: June 21, 2015, 05:27:58 am »
That's the way keyboards are made. Your problem is called keyboard ghosting.

Oh that's interesting, thanks very much for the help, appreciate it!

 

anything