Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
104 stars 82 forks source link

Ctrl+W closes browser games #8003

Closed TackerTacker closed 3 weeks ago

TackerTacker commented 3 weeks ago

Problem description

Yesterday it came to my attention that [ Ctrl+W ] closes browser tabs, and therefore C3 games, without any warning.

[ WASD ] are the de facto standard keys to move a character in games, the [ Ctrl ] key is also a commonly used key and even if it isn't used it is easy to hit by accident. [ Ctrl+W ] is a very unfortunate key binding for such an impactful shortcut, I know it is a browser thing not something done by Scirra, but is there anything Scirra can do to prevent this? I saw C3 closes without any warning with [ Ctrl+W ] too, but only if there are no unsaved changes, then C3 actually shows a popup with a warning. Blocking [ Ctrl+W ] would be the ideal thing, but could it otherwise be the default behavior for HTML5 exported games to always show a popup with a warning that the player hit [ Ctrl+W ] which will close the game and ask if they really want to do that?!

( I know technically this is not really a bug, but I didn't really know where to post it. Not accidentally closing a game while it's running isn't exactly a feature request either IMO. So I just posted it here for awareness and in hopes of a discussion for a solution. But if that's wrong feel free to just close the issue. )

Attach a .c3p

There is no need for a specific .c3p file because it happens with all projects. But here is a link to a browser game from me that shows that it closes without any warning with [ Ctrl+W ] https://gary-the-world-eater.netlify.app

Steps to reproduce

  1. Go to https://gary-the-world-eater.netlify.app
  2. Press [ Ctrl+W ]
  3. Lose all your progress

Observed result

The game closes without any warning and a player will lose all their progress.

Expected result

The game not closing, or at least show a popup with a warning. The warning text should ask if the player really wants to exit the game, and it should show the shortcut to make it clear to the player why this is happening ( in case they hit the shortcut by accident )

More details

Affected browsers/platforms:

First affected release:

System details

View details PASTE HERE
AshleyScirra commented 3 weeks ago

Web content cannot block Ctrl+W from closing the tab. This is in part to prevent abusive web content from blocking closing tabs (e.g. ads or malicious content which try to make themselves unclosable). So unfortunately I don't believe there is anything that can be done about this.

I suppose a unload handler could be used to show a warning before closing, but I think that falls in to the category of a feature request. It will also still be annoying if anyone presses Ctrl+W by accident.

WilsonPercival commented 3 weeks ago

I found this way to display a warning

ctrl_w_warning.zip

TackerTacker commented 3 weeks ago

@AshleyScirra a warning that pops up if someone hits [ Ctrl+W ] by accident might be annoying, but losing your progress will make people straight up angry. I don't see much interest from you about it though, so I reckon making a feature request for it will just be a waste of my time since it won't be picked anyways.

F3der1co commented 3 weeks ago

The annoying thing with the warning is that it also blocks any type of closing (alt+f4, pressing the "X" close icon etc.), which is really annoying when previewing and testing the game. I do enable it for some of my projects on export though, especially if they use WASD controls