...

View Full Version : Keyboard functions



sherlockturtle
05-20-2011, 02:50 AM
How would i make a keyboard key start a function?

Rowsdower!
05-20-2011, 03:17 PM
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?

sherlockturtle
05-20-2011, 05:08 PM
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??

Rowsdower!
05-23-2011, 05:09 PM
...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=javascript+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.

sherlockturtle
05-23-2011, 05:45 PM
http://www.google.com/#hl=en&q=javascript+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

teedoff
05-23-2011, 05:48 PM
I do use google a ton

not enough maybe? lol

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

sherlockturtle
05-23-2011, 05:50 PM
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

Rowsdower!
05-23-2011, 05:53 PM
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! :thumbsup:

sherlockturtle
05-23-2011, 06:35 PM
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! :thumbsup:

How would you reffer to a arrow key!?

sherlockturtle
05-23-2011, 06:37 PM
OK its called a key code that all i neaded to know!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum