The problem is because your id="txtSearch" is not honored by the xPage. If you look at the source HTML created it looks like this
your code
<xp:inputText id="txtSearch"></xp:inputText>
The XPage makes
<input type="text" id="view:_id1:txtSearch" name="view:_id1:txtSearch" class="xspInputFieldEditBox">
What you are looking to do can be done a number of different way including a class selector
here is the class selector code for the XPage
Cheers,
Mark
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom">
<xc:ccJQueryInvoker></xc:ccJQueryInvoker>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:span
style="color:rgb(0,64,128);font-weight:bold;font-size:18pt;text-decoration:underline">
Welcome to world of JQuery in XPages
</xp:span>
<xp:br></xp:br>
<xp:br></xp:br>
<xp:br></xp:br>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<xp:br></xp:br>
<xp:br></xp:br><xp:inputText styleClass="txtSearch"></xp:inputText>
<input id="textbox" type="text" size="50" />
<div>
<label>1. keyup() Message :</label> <span id="msg-keyup"></span>
</div>
<div>
<label>2. keydown() Message :</label><span id="msg-keydown"></span>
</div>
<div>
<label>3. keypress() Message :</label><span id="msg-keypress"></span>
</div>
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
$(".txtSearch").keyup(function(event){
$("#msg-keyup").html("keyup() is triggered!, keyCode = " + event.keyCode + " which = " + event.which)
});
$("#textbox").keyup(function(event){
$("#msg-keyup").html("keyup() is triggered!, keyCode = " + event.keyCode + " which = " + event.which)
if(event.which == 13) {
alert("Enter Pressed");
}
else {
alert("Other");
}
});
});]]></xp:this.script>
</xp:eventHandler>
</xp:view>