How do I capture a key press (or keydown) event on a div element?

(1) Set the tabindex attribute: <div id=”mydiv” tabindex=”0″ /> (2) Bind to keydown: $(‘#mydiv’).on(‘keydown’, function(event) { //console.log(event.keyCode); switch(event.keyCode){ //….your actions for the keys ….. } }); To set the focus on start: $(function() { $(‘#mydiv’).focus(); }); To remove – if you don’t like it – the div focus border, set outline: none in the CSS. … Read more

Remove part of path on Unix

If you wanted to remove a certain NUMBER of path components, you should use cut with -d”https://stackoverflow.com/”. For example, if path=/home/dude/some/deepish/dir: To remove the first two components: # (Add 2 to the number of components to remove to get the value to pass to -f) echo $path | cut -d”https://stackoverflow.com/” -f4- # output: # some/deepish/dir … Read more

Updating every profile’s registry on Windows Server 2003

Active Setup is no longer advisable (original source). There are several ways to achieve what you want – one clunkier than the other. Terminal servers can be a deployment nightmare – users may not have rights to run msiexec.exe and hence MSI self-repair could fail. That’s why I generally prefer to use batch files, scripts … Read more

tech