I need to send form input to js function after keypress `enter`

Following answer <https://stackoverflow.com/a/905233/6827096> but below code refreshing page after pressing `enter`.

```
#.html
<script src="chat.js'"></script>
<input  onkeypress="return sendChatMessage(event)">

#chat.js
function sendChatMessage(e) {
    if (e.keyCode == 13) {
        console.log("e.keyCode == 13");   //never reachable
        return false;
    }
    return true;
}

```

How to avoid refreshing page with event onkeypress ENTER (keyCode == 13) ?

Function `sendChatMessage` is visible in browser console with page loaded.