Hi!
I have a problem. I want to send from a html to a c# program the keyboard events.
When i press the SHIFT it works, but if i doesn't press SHIFT, it is dummy :(
Can somebody help me to write a right code for it?
I use json in my script, what sends to to my program the right ACSII codes, my program receives it, but it is not correct :S
$("body").bind("keypress", function (event) {
chCode = ('charCode' in event) ? event.charCode : event.keyCode;
char = String.fromCharCode(event.which);
console.log("char:" + char + " which:" + event.which + " keyCode:" + event.keyCode + " charCode:" + event.charCode);
json = '{"eventID":"keypress","charCode":"' + event.which + '"}';
ws.send(json);
});
case "keypress":
charCode = (string)(jsonObj["charCode"]);
byte keyCode = (byte)Convert.ToInt32(charCode);
str = Convert.ToString(Convert.ToChar(Convert.ToInt32(charCode)));
Console.WriteLine(str);
Console.WriteLine(keyCode);
const int KEYEVENTF_EXTENDEDKEY = 0x1;
const int KEYEVENTF_KEYUP = 0x2;
keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(keyCode, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
break;
Thank you for helping me, and sorry my bad english!