KeyCode of enter key cannot be detected in inside of INPUT control?

  node.js, question

$(document).ready(function () {

$('#tagInput').on('keypress',function (event) {
 
 Log ('entry:' plus event.keyCode);
 if(event.keyCode === 32 || event.keyCode === 13 ){console.log(true)}
 })

})
Well, I can detect other keyCode in the inside of this type text control, that is, after pressing enter, I will only jump out of the focus of this control, and will not detect the event. Solve?

Because the keypress event will only be triggered when the character key (letter/number/punctuation/element symbol, etc.) is pressed, the enter key will not trigger the keypress event, and the keyup or keydown event can be used.