Allow right clicks in games (instead of showing browser right click menu) #13

Closed
opened 2026-06-04 19:10:56 +02:00 by brettchalupa · 1 comment
Owner

chronoboy. in Discord:

Oh, it's really easy to have a game work seamlessly with both mouse and gamepad, and alternate between the two. The game I am working on supports both, with mouse, you just click on stuff, but in gamepad/keyboard mode, where it uses the standard BTN? stuff, and shows a simple cursor on the screen when needed to allow the exact same actions. The util.point_in_rect I think it's called is perfect for mouse support, as the point is where your mouse cursor is, and the rect is say a button, or a object. With this, you can easily know if the player has their mouse over something, or has click something.
...
I figured it out, looked through the exported index.html file, and looked up how to disable the content menu, and inserted this in the first

chronoboy. in Discord: > Oh, it's really easy to have a game work seamlessly with both mouse and gamepad, and alternate between the two. The game I am working on supports both, with mouse, you just click on stuff, but in gamepad/keyboard mode, where it uses the standard BTN? stuff, and shows a simple cursor on the screen when needed to allow the exact same actions. The util.point_in_rect I think it's called is perfect for mouse support, as the point is where your mouse cursor is, and the rect is say a button, or a object. With this, you can easily know if the player has their mouse over something, or has click something. > ... > I figured it out, looked through the exported index.html file, and looked up how to disable the content menu, and inserted this in the first <script> block right after the <canvas>, and right-click will work in Usagi. fix they used: window.addEventListener('contextmenu', (event) => { event.preventDefault(); });
Author
Owner

fix they used:

window.addEventListener('contextmenu', (event) => {
  event.preventDefault();
});
fix they used: ``` window.addEventListener('contextmenu', (event) => { event.preventDefault(); }); ```
brettchalupa added this to the v1.1.0 milestone 2026-06-04 19:16:17 +02:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
brettchalupa/usagi#13
No description provided.