Send Which Key That Was Pressed To File
Hi I got a question that I would like to get some help with. First I was wondering how to detect which key that was pressed and then after that send the key that was pressed to ano
Solution 1:
window.location.href="Test3.html/?charCode=" + charCode;
This will give your page 'Test3.html' access to the GET parameter 'charCode'. Though you'd probably want to use a server-side language to do something useful with it, since IMO it is a bit of a hassle to manipulate GET parameters from javascript.
Solution 2:
PHP
<script>
$(document).keypress(function(event){
var key = event.keyCode;
</script>
$.ajax({
type: "POST",
url: "<?php echo myphp.php ?>",
data: {
'events': key
},
success: function(data)
{
},
complete: function()
{
}
});
myphp.php
$key = $_POST['events'];
$myfile = fopen("filename.txt", "w") or die("Unable to open file!");
fwrite($myfile, $key);
fclose($myfile);
Post a Comment for "Send Which Key That Was Pressed To File"