I have been reading through many articles relating to this but they only show how to prevent anything happening not only the page refresh.
But I need to have it so when enter key is pressed the text field is submitted via a ajax request without the page refresh, like how I can use the input type button with a onclick event.
iv added a very basic mock up below to help explain what I mean.
<html>
<head>
<title>Demo</title>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.2/jquery.min.js'></script>
</head>
<body>
<form id="someForm" action="" method="post">
<!--
below is an example of the text field
id like to submit but without the
page refreshing when "Enter" is pressed
-->
<input type="text" id="demoText"/>
<button type="button" id="postBtn" onclick="postText()">Post</button>
</form>
<script>
function postText() {
alert("Random Function...");
}
</script>
</body>
</html>