Send message using keypress event

I am using ui_template. I would like to send payload at the time of clicking "enter" key. I am using the below script. but not working. But alert function working fine in keypress event.

<script>
        
            $(function ($scope) 
            {
                $('.decimal').keypress(function decimal(e) 
                {
                    if (event.key === 'Enter') {
                        $scope.send({payload: "test"});  
                       // alert($(this).val());
                        /*(function($scope) {
                        $scope.send({payload: "test"});   
                                })(scope);
                        
                        alert($(this).val());*/
                        
                    }
                    var character = String.fromCharCode(e.keyCode)
                    var newValue = this.value + character;
                    if (isNaN(newValue) || parseFloat(newValue) * 1000 % 1 > 0) {
                        e.preventDefault();
                        return false;
                    }
                })(e);

            })(scope);
        </script>

html input i am using to access the script.

<input type="text" id="salary" class="decimal"  />

Kindly help me to send output in keypress event.

Try something along the lines of...

$('.decimal').on('keypress',function(ev) {
    var keycode = (ev.keyCode ? ev.keyCode : ev.which);
    if(keycode == 13) {
        //Enter pressed
    }
});