Jump to content

Overwrite button Combinations like ctrl+s


Pryme8
 Share

Recommended Posts

this solves the save shortcut, but not the ctrl+w to close tab shortcut

$(window).keypress(function(event) {
    event.preventDefault();
    return false;
});

I really need to figure out how to stop the tab from closing when a user crouches with ctrl and try to move forward.

Link to comment
Share on other sites

Hi  @Pryme8 I got this from stackoverflow a while back, i don't have a link though.

 

window.onbeforeunload = function () {//Prevent Ctrl+W in chrome
    return "Really want to quit the game?";
};

document.onkeydown = function (e) {
    e = e || window.event;//Get event
    if (e.ctrlKey) {
        var c = e.which || e.keyCode;//Get key code
        switch (c) {
            case 83://Block Ctrl+S
            case 87://Block Ctrl+W --Not work in Chrome
                e.preventDefault();     
                e.stopPropagation();
            break;
        }
    }
};

Update; To my understanding, no matter what you do, Chrome reserves Ctrl + W for tab closing and it cannot be stopped, chrome ignores your javascript, the above solution by using onbeforeunload is the only way to avoid it closing the tab imitiately, but ofc it will make a popup window instead, so i would suggest allowing other keys to be used.

Link to comment
Share on other sites

@Pryme8 - it appears you have an artifact which is redrawing the sphere onto your canvas which appears quite tiny in the center of your screen. If what I'm seeing is indeed an artifact which is not meant to be drawn, then you might want to update your camera. I haven't reviewed your code, but if this is an artifact which you do not want to be drawn, then using .updateCamera(); in reference to your SpriteRoot class object(s) should do the trick. But I'll assume that you already know this, so please ignore if it's simply not an issue.

Obviously, I just took a quick look at your link, and thought I'd offer up my obvious first thoughts; just to make me look smart.:blink:

Cheers,

DB

Link to comment
Share on other sites

@Pryme8 - Again, I assumed this probably had a purpose. I only thought to mention this as I saw this in other posts you currently have online and thought it might be a common artifact which many users overlook. So please ignore my "ever so wise" observation which obviously isn't an issue.

Cheers,

DB

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...