Is Capturing keypress in a designMode IFrame possible?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jay  Xx

    Is Capturing keypress in a designMode IFrame possible?

    I have an IFrame in design mode. I've tried a bunch of things to
    capture key presses in that IFrame, but I can't seem to get it. I can
    capture key presses outside the IFrame fine. I have this problem in
    Firefox, not IE.
    I do know it's possible because Blogger.com's rich text editor does it,
    but their code is cryptic and separated into like 20 files, so I'm
    going through hell trying to decipher it.
    (I need to capture the keypress in order to cancel Ctrl-B from opening
    the bookmarks sidebar)

  • Martin Honnen

    #2
    Re: Is Capturing keypress in a designMode IFrame possible?



    Jay Xx wrote:
    [color=blue]
    > I have an IFrame in design mode. I've tried a bunch of things to
    > capture key presses in that IFrame, but I can't seem to get it. I can
    > capture key presses outside the IFrame fine. I have this problem in
    > Firefox, not IE.[/color]

    It shouldn't be any different to capturing key events in a normal
    iframe. Do you really have code capturing key events in a normal iframe
    with Mozilla that stops working if you switch designMode on for that iframe?
    Could you post a URL where that happens? Do you get script errors? What
    exactly goes wrong, capturing the key event with a handler, or perhaps
    only cancellation of a key?

    --

    Martin Honnen

    Comment

    • Jay  Xx

      #3
      Re: Is Capturing keypress in a designMode IFrame possible?

      Yes, here is a simple example of it not working:

      I don't get any errors. The event simply isn't captured.

      I've also uploaded

      In this example I've commented out the designMode setting, and instead
      I've put a textarea in the IFrame. Capturing keypresses works fine in
      that example. (Each keypress brings up an alert box)

      Comment

      • Jay  Xx

        #4
        Re: Is Capturing keypress in a designMode IFrame possible?

        After extensively searching Blogger.com's code, I've found the rather
        simple solution:

        document.getEle mentById('edit' ).contentWindow .addEventListen er('keypress',
        cK, true);

        Thanks anyway!

        Comment

        • Martin Honnen

          #5
          Re: Is Capturing keypress in a designMode IFrame possible?



          Jay Xx wrote:
          [color=blue]
          > Yes, here is a simple example of it not working:
          > http://www.jayssite.com/misc/iframesample.html
          > I don't get any errors. The event simply isn't captured.[/color]

          I am not sure what is different but here is an example working for me
          with Mozilla 1.7
          <http://home.arcor.de/martin.honnen/javascript/200503/test2005031201. html>
          Onload the keypress handling is enabled and when the user types in the
          iframe the key/char code is reported.
          There are buttons then to disable the keypress handler and enable it
          again which work too.

          Although I also put in some code in that example geared towards IE I
          haven't tested with IE as your original post says you are not looking
          for an IE solution.


          --

          Martin Honnen

          Comment

          Working...