..:: Blog ::..

 ToolBook Blog Minimize

Aug 13

Written by: Tomas Lund
Wednesday, August 13, 2008 12:08 PM

or

"Using a combination of keys to create keyboard shortcuts for navigation"

In my previous article "Keyboard shortcuts in ToolBook HTML" I showed how one can implement keyboard shortcuts using the arrow keys to navigate between the pages.

Now what if you wanted to use a combination of keys to navigate?

Using the SHIFT or CTRL keys along with the arrow keys would only require a small tweak of the example I used in my first article on keyboard shortcuts.

The original on key up handler looked like this:

-- On key up... ----------------------------------------------------------------
Comment: Tomas Lund, ToolBookConsulting.com, July 2008
Comment: Navigate when the user press the arrow keys or the end key while pressing the ALT key
If keyCode = 37
  Comment: User pressed the Left arrow key
  Go to the previous page
Else if keyCode = 39
  Comment: User pressed the Right arrow key
  Go to the next page
Else if keyCode = 35
  Comment: User pressed the END key, now trigger self is the same as the user clicking the button
  Trigger Self
End if

The on keyup handler has three parameters in total
keyCode which holds the value of the key that was pressed, and the shiftDown and ctlrDown parameters which will be true if the shift and ctrl keys are pressed and or false if they are not

 So for instance if we want to make CTRL plus the left arrow go to the previous page and so on, we just need to change the code to this:

-- On key up... ----------------------------------------------------------------
Comment: Tomas Lund, ToolBookConsulting.com, July 2008
Comment: Navigate when the user press the arrow keys or the end key while pressing the CTRL key
If ctlrDown
Comment: User pressed the CTRL key
 If keyCode = 37
   Comment: User pressed the Left arrow key
 Go to the previous page
 Else if keyCode = 39
   Comment: User pressed the Right arrow key
   Go to the next page
 Else if keyCode = 35
   Comment: User pressed the END key
   Comment: trigger self is the same as the user clicking the button
   Trigger Self
 End if
End if

Note I haven’t created a sample for this as the above change is fairly simple to apply to my previous example which you can download from the download page.

I hope this makes sense, As always I appreciate comments, questions and suggestions below.
 

Tags:

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel  

  
 Search Minimize


  
 Quick links Minimize


  
 Blog List Minimize


 Print   


Copyright 2007 by ToolBookConsulting.com   Terms Of Use  Privacy Statement