Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Need Help

Need Help

Scheduled Pinned Locked Moved Web Development
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vanhawk
    wrote on last edited by
    #1

    It is possible to use the [CTRL + W] on the code to close the window or browser? If possible can i have a sample code. Thanks and Regards

    G S 2 Replies Last reply
    0
    • V vanhawk

      It is possible to use the [CTRL + W] on the code to close the window or browser? If possible can i have a sample code. Thanks and Regards

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Try to write a useful subject line. Almost every thread is about someone who needs help, so that doesn't do anything at all to distinguish your thread from other.

      vanhawk wrote:

      It is possible to use the [CTRL + W] on the code to close the window or browser?

      No, you can't feign keypresses from Javascript.

      --- "Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things." -- Douglas Adams

      1 Reply Last reply
      0
      • V vanhawk

        It is possible to use the [CTRL + W] on the code to close the window or browser? If possible can i have a sample code. Thanks and Regards

        S Offline
        S Offline
        SABhatti
        wrote on last edited by
        #3

        yes it is possible. You have to use combination of onkeydown, onkeyup, and onkeypress functions to catch the keys and call window.close() to close the window. You will be calling these function in body tag. onkeydown you will be checking for ctrl key and initialize the flag for it, onkeyup reset the flag for ctrl, onkeypress check the keycode for W and if ctrl key flag is true and it is W then close the window. This is my understanding, but you might have to play with it. I have done it but it was way past and I don't have the code with me right now.

        -----

        V 1 Reply Last reply
        0
        • S SABhatti

          yes it is possible. You have to use combination of onkeydown, onkeyup, and onkeypress functions to catch the keys and call window.close() to close the window. You will be calling these function in body tag. onkeydown you will be checking for ctrl key and initialize the flag for it, onkeyup reset the flag for ctrl, onkeypress check the keycode for W and if ctrl key flag is true and it is W then close the window. This is my understanding, but you might have to play with it. I have done it but it was way past and I don't have the code with me right now.

          -----

          V Offline
          V Offline
          vanhawk
          wrote on last edited by
          #4

          thanks for the idea

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups