neulowii Posted September 9, 2020 Share Posted September 9, 2020 Hello, I am trying to implement keyboard inputs in pixi. Unfortunately pixi does not support this function. They are a lot of good examples which I found but none of them really worked perfect. I would like to have some kind of events happening when a key is pressed and the PIXI.Container is focused. (like its working with mouse) Example how I want it to work: 1. main PIXI.Container (stage) have the possibility to move a character with WASD-keys(easy to do) 2. textinput (chat) which is a child of the stage, writing text without perform the events on the parent when pressing WASD It would be possible to disable all keys on textinput and enable them again on mouse click on the parent again. But it would be a little bit hacky. Is there a better way which exist or how are you doing this? Quote Link to comment Share on other sites More sharing options...
KayacChang Posted September 13, 2020 Share Posted September 13, 2020 I think it is wised decision that pixijs team exclude keyboard event. because pixijs is a "render" library not "game" engine. The easiest way is listening the keyboard event fire from "window" or "document". Please see [KeyBoard Event](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent). If you keep going you will start deal with the issued like:[Sync keyboard event to requestAnimationFrame] (https://gist.github.com/KayacChang/861f6be2970f47eaccc6b0814a930ccf). The second requirement is about the three topic: 1. how to deal with focus, like "focus event" 2. how to manage the "state" in the application, like "store the current focus target" 3. change the application behavior by the state change, like "observer pattern" ivan.popelyshev and neulowii 2 Quote Link to comment Share on other sites More sharing options...
neulowii Posted September 14, 2020 Author Share Posted September 14, 2020 (edited) Thanks, I was just thinking if they would exist a general solution. Since I am just using only a chat and the game world itself I am using the pointerover to change the focus. Is there a possibility to not fire events to the parent and so on if both the child and parent is interactive with the same events? Edited September 14, 2020 by neulowii Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.