how can I pass arguments to keydown event

I have a function inside that I will call

$document.on('keydown', handleKeyPress);

var handleKeyPress = function (event) {
    var keyCode = (event.which) ? event.which : event.keyCode;
    // some logic
}

But here I want to pass $element as an argument to handleKeyPress. I have tried this code

   $document.on('keydown', handleKeyPress($element, event));
   
   var handleKeyPress = function (element, event) {
      var inputElement = element;
      var keyCode = (event.which) ? event.which : event.keyCode;
      // some logic
   }

but it’s throwing an error Uncaught TypeError: Cannot read property 'call' of undefined at defaultHandlerWrapper (angular.js:3840)...... Please help me with this, any help will be appreciated. Thank you in advance.

Answer

Try in this way:

$document.on('keydown', (event) => handleKeyPress($element, event));

var handleKeyPress = function (element, event) {
 // your logic
}