Help needed - Binding a hotkey function to element with focus

Help needed - Binding a hotkey function to element with focus

I am binding a function to a keydown event.

I am using the js-hotkey plugin which is working fine independently. However when i add a function to bid too im having problems.


Heres my code....

//identify input with focus
$('input[name=autoSaveOrderItem]').livequery('focus', function() {
//identify id of row with focus   
var row = $(this).parent().parent().attr('id');
//F6 duplicate item line
$(document).bind('keydown', 'f6', function (){
duplicateOrderItem(row); 
//return false; 
});
}).livequery('blur',function() {
var row = null;
//unbind access key - f8
$(document).unbind('keydown', 'f6', function (){
return false;
});
});

I am successfully binding the function on focus in the first instance and it all works correctly. However when i apply focus to the next input field and press the f6 key the binded function now fires twice.

I assume this means that the unbind part above is not working but im not sure why?

Any help would be fantastic! 
    • Topic Participants

    • ben