You can use the onkeypress Event in JavaScript.
Here is a sample
<asp:textbox id="Textbox1" runat="server" ></asp:textbox>
Javascript function to be called on KeyPress event
function Samplefunction()
{
alert('You have pressed a key inside the textbox');
}
In your code behind file you can call the javaScript function using the below line.
Textbox1.Attributes.Add("onkeypress", "Samplefunction()");
When ever you enter some text in the textbox an alert message pops up.
Refer this link for more information on KeyPress event
onkeypress Event[
^]
Hope this helps.