Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post

    Keyboard functions

    How would i make a keyboard key start a function?

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Generally speaking, you use an event listener to check for keydown or keyup (or both - depending on what you need) to check and see which key is being used. Then, if it is the key you want to use as a trigger you execute the function.

    Google can provide resources for this. Have you searched yet? Do you have any code started for this?
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #3
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Rowsdower! View Post
    Generally speaking, you use an event listener to check for keydown or keyup (or both - depending on what you need) to check and see which key is being used. Then, if it is the key you want to use as a trigger you execute the function.

    Google can provide resources for this. Have you searched yet? Do you have any code started for this?
    How do you specity the arrow keys??

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by Rowsdower! View Post
    ...Google can provide resources for this. Have you searched yet? Do you have any code started for this?
    http://www.google.com/#hl=en&q=javas...keyboard+codes

    Seriously? Come on! Take some initiative and use Google.

    You capture the "key code" and test its value against the value you are looking for. If it's a match, you execute your code.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #5
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Rowsdower! View Post
    http://www.google.com/#hl=en&q=javas...keyboard+codes

    Seriously? Come on! Take some initiative and use Google.

    You capture the "key code" and test its value against the value you are looking for. If it's a match, you execute your code.
    I do use google a ton

  • #6
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Quote Originally Posted by sherlockturtle View Post
    I do use google a ton
    not enough maybe? lol

    http://www.dreamincode.net/code/snippet1246.htm
    Teed

  • #7
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Rowsdower! View Post
    Generally speaking, you use an event listener to check for keydown or keyup (or both - depending on what you need) to check and see which key is being used. Then, if it is the key you want to use as a trigger you execute the function.

    Google can provide resources for this. Have you searched yet? Do you have any code started for this?
    I have lookedit up bit how do you specify the arrow keys

  • #8
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Yeah, I'm sorry but I go no further than this without some evidence that you have done some work for yourself.

    Post some code (or a very specific question relating to the execution of the code) after you have read up on the links at the google search I provided you with and/or the link teedoff gave to you (and any other reading you may do on YOUR OWN google searches) and I will come back to this thread.

    Until then, I'm out!
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #9
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Rowsdower! View Post
    Yeah, I'm sorry but I go no further than this without some evidence that you have done some work for yourself.

    Post some code (or a very specific question relating to the execution of the code) after you have read up on the links at the google search I provided you with and/or the link teedoff gave to you (and any other reading you may do on YOUR OWN google searches) and I will come back to this thread.

    Until then, I'm out!
    How would you reffer to a arrow key!?

  • #10
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    OK its called a key code that all i neaded to know!


  •  

    Posting Permissions

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