How to disable CTRL+J firefox shortcut using javascript funcions?

Hi,
I have to use a Barcode-reader in a web application and the code should be put in a jsp text field.
The barcode-reader maps the keyboard shortcut in the right way but after then sends a byte sequense like ENTER (ascii 13) and CTRL-J that open the Firefox download window.

My question is how can I disable the CTRL-J shortcut?
And if it's no possible, how can I send CTRL-J by javascript function?

Thanks

Re: How to disable CTRL+J firefox shortcut using javascript ...

function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array(‘a’, ‘n’, ‘c’, ‘x’, ‘v’, ‘j’);
var key;
var isCtrl;

if(window.event)
{
key = window.event.keyCode; //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which; //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}

//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i

Re: How to disable CTRL+J firefox shortcut using javascript ...

function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array(‘a’, ‘n’, ‘c’, ‘x’, ‘v’, ‘j’);
var key;
var isCtrl;

if(window.event)
{
key = window.event.keyCode; //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which; //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}

//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i

Re: How to disable CTRL+J firefox shortcut using javascript ...

Im doing the same, working with barcode readers.
Based on this

Workaround if you have one:
In order to change a keycode, you need to cancel the current event, and
dispatch a new key event with the new keycode. 
 
public class FireFoxTextBox extends TextBox {
        public void onBrowserEvent(Event event) {
            int type = DOM.eventGetType(event);
            if (type == Event.ONKEYPRESS) {
                   changeKeyCode(event);
            } else
                super.onBrowserEvent(event);
        }
 
        public native void changeKeyCode(Event event) /*-{
 
           if (String.fromCharCode(event.charCode) == "Q") {
                  var newEvent = document.createEvent("KeyEvents")
                  newEvent.initKeyEvent("keypress", true, true,
document.defaultView,
                  event.ctrlKey, event.altKey, event.shiftKey,
                  event.metaKey, 0, "F".charCodeAt(0))
                  event.preventDefault()
                  event.target.dispatchEvent(newEvent)
           }
        }-*/;
 
    }

I did this

<script>
function pressed(e){
	if(e.ctrlKey){
		e.preventDefault();
	}
}
<script>
 
<body>
<INPUT id=barcode type=text onkeydown="pressed(event)">
</body>

Use your mind :D

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img>
  • You may quote other posts using [quote] tags.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • You can use BBCode tags in the text. URLs will automatically be converted to links.

More information about formatting options