JS keyboard events problem on demo.moodle.net

Re: JS keyboard events problem on demo.moodle.net

by Alex Ptroch -
Number of replies: 0

It turns out, there an iframe is used.

Here is the solution:


var win = false;
var par = false;
if (window) {
   if (window.frameElement) {
      if (window.parent && (window.parent != window)) {
         win = true;
         par = true;
      }
      else {
         win = true;
      }
   }
   else {
      win = true;
   }
}
if (win) {
   window.onkeypress = _this.keyPressW;
   window.onkeydown = _this.keyDownW;
   window.onkeyup = _this.keyUpW;
}
if (par) {
   window.parent.onkeypress = _this.keyPressW;
   window.parent.onkeydown = _this.keyDownW;      
   window.parent.onkeyup = _this.keyUpW;
}


Thank you. The topic is closed.