Sign in to follow this  
QuackCoder

[web] Getting multiple key input and confusing keycodes

Recommended Posts

[size="3"]1. So how do I listen for multiple (simultaneous) key inputs? I can only listen for one.
2. Lowercase and Uppercase character have different key codes. Is there a way to deal with them rather than hard coding?

EDIT: Using javascript
[/size]

Share this post


Link to post
Share on other sites
It would be helpful to know what languege you use and what api you are using for inputs.

1. What do you mean with "listening"? Normally you should have an array bool keys[256] and set a certain position to true if a certain key is pressed. That way you can check for as many keys as you'd want at the same time.

2. For c++ and the windows api, lower and uppercase didnt make a differnce so far for me. As I said, tell us what you are working with..

Share this post


Link to post
Share on other sites
[quote name='The King2' timestamp='1317384940' post='4867551']
It would be helpful to know what languege you use and what api you are using for inputs.
[/quote]

I using plain old javascript.
[code]
<!DOCTYPE html>
<html>
<head>
<title>page</title>
<script type="text/javascript">
function addEventListener(){
function getKey(e){
var keyCode = e.which || e.keyCode;
return keyCode;
}
document.addEventListener('keydown', getKey, false);
}
</script>
</head>
<body onload="addEventListener()">
</body>
</html>
[/code]
But this would give me only one keycode.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this