Schmavery / reprocessing

ReasonML graphics library inspired by Processing
https://schmavery.github.io/reprocessing/
MIT License
679 stars 24 forks source link

Key press detections fails with certain combos #105

Open Lyonsclay opened 5 years ago

Lyonsclay commented 5 years ago

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);
Schmavery commented 5 years ago

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

Lyonsclay commented 5 years ago

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);
Schmavery commented 5 years ago

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?