1

i wants to submit a php form with any of function key or a Any of keyboard shortcut key.

I try following code. In that i do operation using keyboard keycode. but its not submits the form. Press "TAB" button from Keyboard

document.onkeydown=function(evt){
        var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
        if(keyCode == 9)
        {
            //your function call here
            document.test.submit();
            alert("Key Pressed");
        }
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<?php 
if(isset($_POST['search']))
{
    echo $search = $_POST['search'];
}
?>
<body>
<form name="test" action="#" method="POST">
 <input type="text" name="search" />
</form>
</body>

I wants to submit a PHP form with any of Function key or Any of combinations or shortcut key. So How can I do it with JQUERY,JS,AJAX OR PHP.

3 Answers3

1

I founded a JS to Allow Form Submit using keyboard key combination. It quite easy. See Code

    shortcut.add("Ctrl+B",function() {
    document.getElementById("sbmt").click();
    alert("Form Submitted...");
    },{
      'type':'keydown',
      'propagate':true,
      'target':document
    });

When Press Ctrl + B Form Was Submits. This is Link to JS openjs To Allow Shortucut

Amar Singh
  • 5,464
  • 2
  • 26
  • 55
0

try this it will work.

document.onkeydown=function(evt){
    var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
    if(keyCode == 9)
    {
        //your function call here
        document.forms["test"].submit();
        alert("Key Pressed");
    }
}

Check this code in your local not on third party. This will work perfect on localhost. this is work for me.

Devendra Gokhe
  • 187
  • 1
  • 1
  • 10
0

Checkout this if you want to submit on click of any function keys JsFiddle

$(document).keyup(function(e) {
   if(e.which <124 && e.which >111){
   alert('function keys');
   //submit your form here
   }

});
Amar Singh
  • 5,464
  • 2
  • 26
  • 55