Intercept Ctrl+J in textboxhttp://forums.asp.net/t/1793896.aspx/1?Intercept+Ctrl+J+in+textboxThu, 19 Apr 2012 17:01:07 -040017938964937188http://forums.asp.net/p/1793896/4937188.aspx/1?Intercept+Ctrl+J+in+textboxIntercept Ctrl+J in textbox <p>Hello all,</p> <p>I'm working with a barcode reader, and after all input, it sends a CR and a CTRL&#43;J, which open the bookmarks window.</p> <p>Is there anyway of intercepting (and avoiding) this behavior? Reconfigure the barcode for CR only or TAB, unfortunately, is not an option.</p> <p>Thanks in advance for any help,</p> <p>Marcelo</p> 2012-04-17T17:06:11-04:004937242http://forums.asp.net/p/1793896/4937242.aspx/1?Re+Intercept+Ctrl+J+in+textboxRe: Intercept Ctrl+J in textbox <p>You should be able to handle this using Javascript:</p> <pre class="prettyprint">&lt;script type='text/javascript'&gt; document.getElementById('yourBarcodeInputId').onkeydown = function(e){ //If CTRL&#43;J is pressed... if(e.ctrlKey &amp;&amp; e.keyCode == 'J'.charCodeAt(0)) { //Prevent Default (Bookmark Display) from occurring e.preventDefault(); //Handle your CTRL&#43;J functionality here... } } &lt;/script&gt;</pre> <p><a href="http://jsfiddle.net/4vk5u/"><strong>Working Demo</strong></a></p> <p>PreventDefault should override the original functionality that the browser uses to display the bookmarks and you can then execute your logic following that. You can find an article <a href="http://unixpapa.com/js/key.html">here</a> with further details on using Javascript to handle these type of events.</p> 2012-04-17T18:06:55-04:004941523http://forums.asp.net/p/1793896/4941523.aspx/1?Re+Intercept+Ctrl+J+in+textboxRe: Intercept Ctrl+J in textbox <p>Thanks a lot, worked like a charm.</p> 2012-04-19T16:58:04-04:004941531http://forums.asp.net/p/1793896/4941531.aspx/1?Re+Intercept+Ctrl+J+in+textboxRe: Intercept Ctrl+J in textbox <p>Glad it helped you out :)</p> 2012-04-19T17:01:07-04:00