I am making this snake-game, and i am trying to make it playable on as many devices as possible. When i loaded my snake website on my ps4 browser, it worked fine, until i tried to move the snake. I didn't have ps4 controller events keys in my javascript, so i tried to find out what the event keys are on a ps4 controller. I tried it with this code:
window.addEventListener('keydown', (e) => {
window.alert(`key: ${e.key}, keycode: ${e.keycode}`)
// i am using alert() instead of console.log() because the ps4 browsers does not have a console. So the console does not have a console haha
})
when i press a button on my controller i get an alert with: key: code: undefined. I have no idea how to figure out if it's possible to let my snake move on ps4, do any of you have a solution? I get the same problem when i connect a keyboard to my ps4 btw
All of my code: https://github.com/LarsVerschoor/LarsVerschoor/tree/main/Snake%20V3.0
You might have to rewrite some of the code but here are the ps4 controller keycodes.
I don't know if this helps but I hope it did