Jump to content

Java Script or Java - Diasble ALT-TAB Key


Recommended Posts

Hi,

I am working on a Project in which the User should not Switch on to any toher application other than mine. I want to disable certain keys like Windows Key and Alt-Tab Combination key. How would I make it Possible.

The Code can be in Java or Java Script.

Link to comment
Share on other sites

  • 2 weeks later...

I do know that its possible...

But just see that the site it results in doesn't start to annoy normal usage. Because, I remember a site which did this:

Has a field where you enter case number (its a legal services site). If you used the "Back" arrow key to correct it, it immediately popped up a dialog-box -

Please enter a number between -blah-blah-blah-
And it did this every-time I pressed an arrow-key or a back-space. I HAD to use the mouse to get the cursor to where I wanted. That really was one annoying experience.
Link to comment
Share on other sites

Uh, that isn't the same thing at all, that's just normal form validation (comparing keystrokes with a allowed keystrokes and with a mask) - gone bad (bad implementation). It's an event of the textbox or whatever that had the focus, and no, they don't have events fot alt-tab. There are ways to prevent a user from switching tasks - but not this way (I don't know your setup - nor why/how you want to do this)

Link to comment
Share on other sites

  • 3 weeks later...

Well Friends,

let me tell you why I want to do this, Just open any Form and Press ALT-TAB Keys Simultaneously. You will Come to One More Window Right All that I need is I dont want user to Pass from MY WINDOW to other window unless he closes it, I know it is Possible and also Done in many Sites.

Link to comment
Share on other sites

  • 1 month later...

ALT+TAB is something inherent to the Windows Operating System and is completely out of reach for JavaScript or any other scripting language :whistle:

(and even any programming language as far as I remember).

there is a way however to return a message to the user when he presses a key when you don't want him to do that :thumbup

<script text="textjavascript"> 
function detect() {
               var pressKey = String.fromCharCode(event.keyCode);
               if (event.altKey) { alert('hello realguru');
               }
};
</script>
<body onkeydown="detect()">

Just detect the onKeyDown event and look for the keycode (event.keycode) or (event.altKey) and either process a return value of false .. or remap the key to some other key.

This is just a scribble, and wouldnt work in NN, or maybe even mozilla firefox because those browsers require a convoluted script to trap and process the onkeydown event.

too tired now to even explain that

I can't think of one good reason for disabling that key :rolleyes:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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