JQuery input limiter

This is a text imput limiter that I wrote and want to remember

Original Limiter Script
function limitInput { $(".editable").keydown(function(event) {            /*              * Control Keys List:              *      8   - Backspace              *      9   - Tab              *      13  - Enter              *      32  - Spacebar              *      37  - Left Arrow              *      38  - Up Arrow              *      39  - Right Arrow              *      40  - Down Arrow              *      188 - Comma              */             var controlKeys = [8, 9, 13, 32, 37, 38, 39, 40, 188];             var isControlKey = controlKeys.join(",").match(new RegExp(event.which))             if (event.shiftKey) {                 event.preventDefault;             } else {                 if(document.getElementById('pGroup').checked){                     if(!event.which || isControlKey || (49 <= event.which && event.which <= 57) || (48 == event.which && $(this).attr("value")) || (97 <= event.which && event.which <= 105) || (96 == event.which && $(this).attr("value"))) {                        return;                     } else {                         event.preventDefault;                     }                 } else if (document.getElementById('cGroup').checked){                     if(!event.which || isControlKey || (49 <= event.which && event.which <= 57) || (48 == event.which && $(this).attr("value")) || (97 <= event.which && event.which <= 105) || (96 == event.which && $(this).attr("value")) || (65 <= event.which && event.which <= 90) || (189 == event.which)) {                         return;                     } else {                         event.preventDefault;                     }                 }             }         }); } This script is then called from the semi-standard javascript starting point. $(document).ready(function {         limitInput;     });

Second adaptation (this one limits length as well as input)

function limitInput { $(".editable").keydown(function(event) {            var controlKeys = [8, 9, 13, 32];             var isControlKey = controlKeys.join(",").match(new RegExp(event.which))             if (event.shiftKey) {                 event.preventDefault;             } else {                 if(!event.which || isControlKey || (49 <= event.which && event.which <= 57) || (48 == event.which && $(this).attr("value")) || (191 == event.which) || (97 <= event.which && event.which <= 105) || (96 == event.which && $(this).attr("value")) || (111 == event.which)) {                    return;                 } else {                     event.preventDefault;                 }             }         }); $('.editable').keyup( function {            var $this = $(this);             if($this.val.length >= 10)                 $this.val($this.val.substr(0, 10));         }); } This script is then called from the semi-standard javascript starting point. $(document).ready(function {         limitInput;     });