[web] Getting multiple key input and confusing keycodes

Started by
1 comment, last by QuackCoder 12 years, 6 months ago
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=2]Sorry, English isn't my first language
Advertisement
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..

It would be helpful to know what languege you use and what api you are using for inputs.


I using plain old javascript.

<!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>

But this would give me only one keycode.
[size=2]Sorry, English isn't my first language

This topic is closed to new replies.

Advertisement