SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Receiving character from keyboard

    Absolutely I'm in trouble.That's my trouble.For Example;
    A program which will receive a character(as CTRL+J,CTRL+G etc.) from keyboard.And compare it with its own ASCII code. Then A new adresses will be opened.
    Thanks for your support

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take a deep breath.

    Think of fields of grass and birds singing in the wind.

    Ready?

    Now talk sense - you fool!

    If you're asking what you do to get the keyCode pressed and the modifier associated with it then you'd use the event tag onkeypress in the body and the event property of keyCode in the function called - and the event modifier for the ctrl is event.ctrlKey or event.ctrlLeft (depending on which control).

    If you don't understand that just say - I'll explain further!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't understand exactly. Could you send the code?

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As per usual - this is completely un-tested and off the top of my head

    Code:
    <script language="Javascript">
    function KeyHandler(){
           var e=window.event;
           var keyCode=e.keyCode;
           if (e.ctrlKey || e.ctrlLeft){
                 if (keyCode == whatever1){
                         doActions('whatever1actions');
                         }
                 else if (keyCode == whatever2){
                         doActions('whatever2actions');
                         }
                 }
           }
    </script>
    <body onkeypress="KeyHandler();">

    Clearer?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm still trying to understand the question

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol @ Skunky

    Well - he's asking if you can set a page up to accept keystrokes to trigger actions.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •