I have requirement to not to use html event handler. So I am trying to handle it from script . I made a small function but it is not working
<head>
<script type="text/javascript">
function lld () {
document.getElementById('me').onkeypress= myfunction()
}
function myfunction(){
alert('hiiiii')
}
</script>
</head>
<body>
<input type="text" id="me" />
</body>
</html>
Try this