The code in the question effectively disables typing from keyboard when the limit has been reached. To impose the restriction on pasted content too, you need to handle other events, too. The following code truncates the textarea content to the given length. This is not good usability (you should probably signal an attempt to exceed the limit, instead of silent truncation, and you could have a character counter on the page to help the user), but it does what was asked for:
<textarea maxlength=2000
onchange="testLength(this)"
onkeyup="testLength(this)"
onpaste="testLength(this)"
></textarea>
<script>
var maxLength = 2000;
function testLength(ta) {
if(ta.value.length > maxLength) {
ta.value = ta.value.substring(0, maxLength);
}
}
</script>