S
S
SlavaMorg2017-04-24 12:25:07
JavaScript
SlavaMorg, 2017-04-24 12:25:07

ctrl+enter keyboard shortcut not working in firefox, how to fix?

Wrote code to send an error message. When selected and pressed ctrl+enter, the function is called. It works in chrome but not in firefox. Help me please.
Here is the code:

document.onkeydown = function (e){
  var txt = '';
  if (txt = window.getSelection) {// Не IE, используем метод getSelection
    txt = window.getSelection().toString();
  } else { // IE, используем объект selection
    txt = document.selection.createRange().text;
  }

  if(e.keyCode == 17)
    ctrl = true;
  else if(e.keyCode == 13 && ctrl && txt != '')
    oFB_mistape.open( txt );
}

document.onkeyup = function (e){
  if(e.keyCode == 17)
    ctrl = false;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-04-24
@Sanasol

www.stackoverflow.com/a/1684236/1603055

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question