Instead of triggering a postback for every key press, it's more efficient to utilize ajax and jquery to achieve your goal.
For more information and examples, refer to this LINK.
Keep in mind that the OnTextChanged event only activates when you lose focus, not while typing, which seems to be your requirement.
A helpful explanation from CodeProject states:
TextChanged: "Occurs when the content of the text box changes between
posts to the server." AutoPostBack: "Use the AutoPostBack property to
specify whether an automatic postback to the server will occur when
the TextBox control loses focus. Pressing the ENTER or the TAB key
while in the TextBox control is the most common way to change focus."
Sample code :
Source : https://jqueryui.com/autocomplete/
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
IMPORTANT : If you still plan to use keypress, consider this quote:
The value of the input text box, during onKeyPress, is always the value before the change.
Furthermore, keypress won't work for "backspace" in chrome.
Sample Fiddle
If you are still curious about OnKeyPress, check out this SO Question.
This is what you are attempting to achieve, but newer and better methods, like HTML 5, have emerged.
Note : The KeyUp Event won't trigger if you use Right click => Paste. Test it out with this Fiddler link.