How block key "esc" on RichFacesPleaseWaitBox?

329 Views Asked by At

I have an implementation of "RichFacesPleaseWaitBox" in my application, but has a problem.

When the user initiates any action, the status starts, displaying the modal "Waiting." When the action finishes execution, the status ends, hiding the modal "Waiting." Until here all right.

However, if the user starts the action, press the "ESC", the modal "Waiting" which had appeared, it disappears, allowing the user to click on the action again, making a new submit.

How can I block "ESC" to get workaround for this problem?

I Have tried that in my modalPanel, but not work.

<rich:hotKey id="hotKeyModalPanelSTATUS" 
handler="alert('false');"
key="esc" />    
2

There are 2 best solutions below

0
On BEST ANSWER

If I got your point correct:

Import mousetrap.js file, follow the jquery documentation, and, finally do a code like this (on you modal shown event, of course):

Mousetrap.bind('esc', function(event){
  event.preventDefault();
  return false;
});

You may also want to unbind the event in the hide event of the modal, so, you can do the following on the hide event:

Mousetrap.unbind('esc');

Hope it helps.

0
On

Well, for now:
using onkeydown and block any esc in my app.
on first js load:

document.onkeydown   

simple:

if(event.keyCode == 27)
 return false;

but, if i want to say "Hello, u press the Esc" in some function, or window .. i can´t .. is a hardcore solution.

If anyone have a better solution, only blocking the ESC efect for request .. plz.. contribute