function h(x)
{
alert(x);
}
<input onkeypress=h(this.value) type=text>
When I press 'a' alert empty
When I press 'b' after 'a' =>ab alert only 'a' and I want 'ab'
When I type 'abcd' it alert 'abc' only and I want 'abcd'
var unicode=e.keyCode? e.keyCode : e.charCode;
typing = document.getElementById('textbox').value + String.fromCharCode(unicode);