reprocessing icon indicating copy to clipboard operation
reprocessing copied to clipboard

Key press detections fails with certain combos

Open Lyonsclay opened this issue 6 years ago • 3 comments

I'm using keyCode detection in a simple game. I have H J K L as motion keys and Space as a firing key.

When H and one of [J K L] are pressed in combination with Space, the Space is not detected.

My guess is that it's an upstream bug, but I wasn't sure where to look.

The following is code I implemented to produce a string of pressed keys for debugging purposes.

let keyStringMap: Reprocessing_Common.KeySet.elt => string =
  fun
  | H => "H"
  | J => "J"
  | K => "K"
  | L => "L"
  | Space => "Space"
  | Nothing => ""
  | _ => "";

let getKeyMap = env : list(string) =>
  List.map(key => Env.key === key ? key : Nothing, [H, J, K, L, Space])
  |> List.map(keyStringMap);

Lyonsclay avatar Jul 07 '18 10:07 Lyonsclay

Is your example right? It seems like that wouldn't compile (looking at the usage of Env.key)

Schmavery avatar Jul 07 '18 20:07 Schmavery

You're right it should be like this;


let getKeyMap = env : list(string) =>
  List.map(key => Env.key(key, env) ? key : Nothing, [H, J, K, L, Space])
  |> List.map(keyStringMap);

Lyonsclay avatar Jul 07 '18 20:07 Lyonsclay

Hmm, not totally sure what's happening. You see it consistently for some key combos but not others? When you use the keyPressed / keyReleased callbacks, do they get triggered correctly? Will take a closer look when I get a chance. Are you seeing this in native or web?

Schmavery avatar Jul 09 '18 00:07 Schmavery