Is it possible?
Or do I really need to remap everything to ones that don’t conflict?
Is it possible?
Or do I really need to remap everything to ones that don’t conflict?
Yes. You can’t ignore or override the browser hotkeys. This would completely mess with user expectations.
For instance if you happen to have an action on F5 or F11 or Ctrl+R or Ctrl+F that would be a total mindf…
Keep in mind that Chrome, Firefox, Edge, Safari all may have different hotkeys. You’re pretty safe though if you use single-letter hotkeys ie WASD or Space.
this is very sad, i need proper Ctrl crouching without Ctrl+D (add mark) and Ctrl+W(close tab), though GPT’s say this:
"
Yes, you can disable browser shortcuts in a WebGL build by adding this JavaScript code to your HTML template (typically located in Assets/WebGLTemplates/
):
// Add to your .html template file
<script>
document.addEventListener('keydown', function(e) {
// Prevent Ctrl/Cmd + key combinations
if (e.ctrlKey || e.metaKey) {
e.preventDefault();
return false;
}
// Prevent specific keys (like F5 for refresh)
if (e.key === 'F5' || e.keyCode === 116) {
e.preventDefault();
return false;
}
});
</script>
Common places to add this:
Library/PackageCache/com.unity.template.webgl-x.x.x/ProjectData~/index.html
Note: Some browser shortcuts (like Alt+F4) cannot be disabled for security reasons. Also, some browsers might still enforce certain shortcuts regardless of JavaScript prevention."
Does it really or something like it work or not for itch.io case anyways?
Like it says, this JS will work for some keys but you would have to check every browser and also risk that any browser update may change the reserved keys.
In your case generally using just Ctrl for input is not going to work. Use Space like most games.
Crouch on Space? But I jump on it, guess will change to just C key or something, though this is more for toggle crouch not hold
also can i use legacy text for WebGL? It seems like it disappears even with best fit in it, only letters remain, in editor everything is okay
No I thought about jumping for Ctrl, Space.
You do support gamepads?
No, no gamepads, also it is hard to make people download, who will ever bring a gamepad to a WebGL game? Also jump on Ctrl is still bad idea cause of Ctrl + W(close tab in Chrome) is like Alt + F4 in PC build.
Check some webgames, ie here: https://crazygames.com/
I recall many of them have gamepad support when they are targeting desktop users.
Well Unity by default supports basic actions for gamepad, like move etc. Anyways even I dont have a gamepad at hand at the moment, also it will be some shooter, its critical to make it mouse and WASD.
Also I’m having issues with Legacy text in WebGL, I guess i should replace it in early stage or there is some setting to make it work as is in editor and PC Build? (best fit didn’t help, it seems WebGL doesn’t take the legacy font, only numbers and _ symbols are working. Reminds me of problem with Default WebGL template fullscreen button killing all the TextMeshPro text which wasn’t made perfectly stable in canvas)
I believe Legacy Text was legacy even before Web builds moved to WebAssembly. I wouldn’t use that on the Web but TMP. Didn’t have any issues with TMP on the web.