SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Tacoma, WA
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to Capture CTRL+SHIFT+P at Same Time??

    I'm working on controlling a windows media player I'm trying to figure out how to control it with keys like CTRL+SHIFT+P to play it. The problem is that I don't know how to capture all three at the same time.

    I'm ONLY supporting IE because that's what the client only want's supported. I have been reading through the forums but nothing about capturing both CTRL+another key or SHIFT+another key.

    If you have any ideas that would completely be helpful.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you look at the event it's self, there should be a keycode which tells you which key was pressed, and as well there should be boolean values telling you whether ctrl, shift etc was pressed.


    have a look at

    http://www.din.or.jp/~hagi3/JavaScri...s/KeyEvent.htm

    You will need to make a few changes to make the checks but its there


  3. #3
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    Tacoma, WA
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just got messenged from a guy in a google group that gave me this code:

    <script type="text/javascript">
    function detect(Event) {
    if(Event==null) {
    alert('null');
    Event=event;
    }

    var msg = 'Key(s) pressed : ';

    var cod = altk = ctrk = shft = false;

    cod = Event.keyCode;
    altk = Event.altKey;
    ctrk = Event.ctrlKey;
    shfk = Event.shiftKey;

    if(cod) msg += cod;
    if(shfk) msg += '\n+ **** Key';
    if(ctrk) msg += '\n+ Ctrl Key';
    if(altk) msg += '\n+ Alt Key';

    alert(msg);

    }

    </script>
    </head>

    <body onkeyup="detect(event)">

    And seems work pretty good. Although one thing I did notice is that when you leave that window and then go back to it then it will no longer detect the key events. Not sure why it does this. If I find the answer then I'll post back here because I know someone else is wanting to know this too!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •