Pixelastic

You can cut our wings but we will always remember what it was like to fly.

Posts tagged with "keyboard"

Productivity tip #1 : Using global hotkeys

This post will be the first of what I hope will be a long serie of posts. I'll blog about some of the little tricks I've learn in the past years that make me go faster on my daily job.

I'll start with something I can no longer work without : my global hotkeys.

The concept is pretty simple, I've binded some keys combinations to launch specific applications or directories. It might not seem very important, but it does make you gain a tremendous amount of time for those apps you launch pretty often like browser, IDE, or project directory.

I used to work on Windows, and I then used a little script named AutoHotKey to bind my keys. The script even comes packaged with its own language if you ever want to script complicated stuff.

I'm now working under Ubuntu, and the global hotkeys can be defined directly from the System Settings (in 11.10 it's System Settings > Keyboard > Shortcuts > Custom Shortcuts)

Opening apps

I choose a key combination hard enough to type so I won't type it by mistake, but easy enough to remember that I could type it whenever I want.

For example, I binded all the app I use the most to a Ctrl+Win+{Letter} combination. Ctrl+Win+C opens Chromium, Ctrl+Win+F opens Firefox, Ctrl+Win+T opens Trillian, etc.

Opening folders

I used a close combination for opening directories : Ctrl+Win+Alt+{Letter}. Those three keys are side by side on most keyboards so pressing them is easy.

This time I used the letter H for my home folder, D for the Dropbox folder, W for /var/www, etc, etc.

I've tweaked my keyboard in a few other ways, but this will be the subject of another post. Hope this one gave you some ideas.

Never use alert() for debugging

One thing I learned today is to never use alert() for debugging pruposes. When the javascript alert() function is called it blocks every other action until the OK button is pressed. It means that your javascript code that is immediatly after the alert() call is delayed until you press OK.

It also means that the thread your browser gave to the javascript engine is halted during all this time.

Imagine you are binding keyboard shortcuts on your website to specific actions. Like pressing Ctrl+S will submit the current form. Of course, Ctrl+S is already defined as a shortcut in the browser, so you will take care of preventing the default behavior in your custom function (using return false, e.preventDefault(), e.stopPropagation() or any method defined in your framework to do that)

The problem is that is you call alert() in your function, the Javascript thread will be halted before you can make the call to stop the propagation and thus, the browser will take control again and firing its default shortcut.

So my advice is that you should never use alert for debugging. Use the console.debug() method shipped in firebur or directly write to the DOM but do not use alert().