oakes/play-cljc

Keycode translation

Closed this issue · 5 comments

It would be really great to have some sane keycodes translation and avoid using playn integers.

  (condp = keycode
    37 :left
    39 :right
    38 :up
    13 :enter
    nil))```
oakes commented

Not sure what you mean; you can add any keycodes you want.

I would like to not find in docs that number 13 is enter. And have :left, :right etc. predefined. So I can directly use keywords. Something like this:

 (contains? #{:enter :space} keycode) 
oakes commented

But that is how it works already. The keyword, not the number, is put in the :pressed-keys set here. So to check if you're pressing the left arrow, you check for the keyword, like this.

well not exactly, :enter is user defined. And I must translate it from 13 to :enter in start.cljs and find that tranformation in docs of e.g. lwjgl. Instead it would be great to have these as part of library as :key_enter with transformation from low-level integer to engene's keyword defined.

oakes commented

I want to keep input and window related code out of play-cljc, since they are very platform-specific. They keycodes for the JS side are completely different than for the lwjgl side, and I don't want to maintain a translation layer for them in the library. It's possible I could make a separate library for doing that, though, like I did with play-cljc.text.