1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv="content-type" content="text/html; charset=utf-8">
5 <link rel="shortcut icon" type="image/ico" href="http://www.sprymedia.co.uk/media/images/favicon.ico">
7 <title>KeyTables example</title>
8 <style type="text/css" title="currentStyle">
9 @import "../../media/css/demo_page.css";
10 @import "../../media/css/demo_table.css";
12 <script type="text/javascript" charset="utf-8" src="../../media/js/jquery.js"></script>
13 <script type="text/javascript" charset="utf-8" src="js/KeyTable.js"></script>
14 <script type="text/javascript" charset="utf-8">
15 function fnMessage ( sMesg )
17 var n = document.getElementById('info');
18 n.innerHTML += sMesg+"<br>";
19 n.scrollTop = n.scrollHeight;
22 $(document).ready( function () {
23 var keys = new KeyTable();
25 /* Focus handler for all cells in last column */
26 keys.event.focus( 4, null, function( nNode, x, y ) {
27 fnMessage( "Cell "+x+","+y+" focused ('live' event - column)" );
30 /* Focus handler for all cells in 8th row */
31 keys.event.focus( null, 7, function( nNode, x, y ) {
32 fnMessage( "Cell "+x+","+y+" focused ('live' event - row)" );
35 /* Focus using coords. */
36 keys.event.focus( 1, 0, function( nNode ) {
37 keys.event.remove.focus( nNode );
38 fnMessage( "Cell 1,0 focus - this event has now been removed" );
41 keys.event.focus( 1, 3, function() {
42 fnMessage( "Cell 1,3 focus" );
45 /* focus with a node */
46 keys.event.focus( $('#example tbody tr:eq(2) td:eq(0)')[0], function() {
47 fnMessage( "Cell 0,2 focus" );
50 /* Blur using a node */
51 keys.event.blur( $('#example tbody tr:eq(1) td:eq(2)')[0], function() {
52 fnMessage( "Cell 1,2 blur" );
55 /* Blur using coords */
56 keys.event.blur( 2, 4, function() {
57 fnMessage( "Cell 2,4 blur" );
61 keys.event.action( 2, 2, function( nNode ) {
62 fnMessage( "Cell 2,2 action" );
63 if ( nNode.style.fontWeight == "" || nNode.style.fontWeight == "normal" ) {
64 nNode.style.fontWeight = "bold";
66 nNode.style.fontWeight = "normal";
70 keys.event.action( 2, 5, function( nNode ) {
71 fnMessage( "Cell 2,5 action" );
72 if ( nNode.style.fontStyle == "" ) {
73 nNode.style.fontStyle = "italic";
75 nNode.style.fontStyle = "";
81 <body id="dt_example">
83 <div class="full_width big">
88 <p>KeyTable allows you to use keyboard navigation on an HTML table. The focused cell is shown through the CSS class ('focus') which in the case below is simply a blue border. Events such as 'focus', 'blur', 'esc' (the escape key) and 'return' (the return key) can be assigned event handling functions thought the API presented.</p>
89 <p>The example shown below has a few cells (selected at random, but near the top) with blur and focus events assigned to them. You can also see the navigation around the table using arrow keys.</p>
92 <div id="info" class="box">
93 Event information:<br>
96 <table cellpadding="0" cellspacing="0" border="0" class="display KeyTable" id="example">
99 <th>Rendering engine</th>
102 <th>Engine version</th>
109 <td>Internet Explorer 4.0 (focus once)</td>
111 <td class="center">4</td>
112 <td class="center">X</td>
116 <td>Internet Explorer 5.0</td>
117 <td>Win 95+ (blur)</td>
118 <td class="center">5</td>
119 <td class="center">C</td>
122 <td>Trident (focus)</td>
123 <td>Internet Explorer 5.5</td>
124 <td>Win 95+ (action/bold)</td>
125 <td class="center">5.5</td>
126 <td class="center">A</td>
130 <td>Internet Explorer 6 (focus)</td>
132 <td class="center">6</td>
133 <td class="center">A</td>
137 <td>Internet Explorer 7</td>
138 <td>Win XP SP2+ (blur)</td>
139 <td class="center">7</td>
140 <td class="center">A</td>
144 <td>AOL browser (AOL desktop)</td>
145 <td>Win XP (action/italic)</td>
146 <td class="center">6</td>
147 <td class="center">A</td>
152 <td>Win 98+ / OSX.2+</td>
153 <td class="center">1.7</td>
154 <td class="center">A</td>
157 <td>Gecko (focus - row)</td>
159 <td>Win 98+ / OSX.2+</td>
160 <td class="center">1.8</td>
161 <td class="center">A</td>
166 <td>Win 98+ / OSX.2+</td>
167 <td class="center">1.8</td>
168 <td class="center">A</td>
173 <td>Win 2k+ / OSX.3+</td>
174 <td class="center">1.9</td>
175 <td class="center">A</td>
181 <td class="center">1.8</td>
182 <td class="center">A</td>
188 <td class="center">1.8</td>
189 <td class="center">A</td>
193 <td>Netscape 7.2</td>
194 <td>Win 95+ / Mac OS 8.6-9.2</td>
195 <td class="center">1.7</td>
196 <td class="center">A</td>
200 <td>Netscape Browser 8</td>
202 <td class="center">1.7</td>
203 <td class="center">A</td>
207 <td>Netscape Navigator 9</td>
208 <td>Win 98+ / OSX.2+</td>
209 <td class="center">1.8</td>
210 <td class="center">A</td>
215 <td>Win 95+ / OSX.1+</td>
216 <td class="center">1</td>
217 <td class="center">A</td>
222 <td>Win 95+ / OSX.1+</td>
223 <td class="center">1.1</td>
224 <td class="center">A</td>
229 <td>Win 95+ / OSX.1+</td>
230 <td class="center">1.2</td>
231 <td class="center">A</td>
236 <td>Win 95+ / OSX.1+</td>
237 <td class="center">1.3</td>
238 <td class="center">A</td>
243 <td>Win 95+ / OSX.1+</td>
244 <td class="center">1.4</td>
245 <td class="center">A</td>
250 <td>Win 95+ / OSX.1+</td>
251 <td class="center">1.5</td>
252 <td class="center">A</td>
257 <td>Win 95+ / OSX.1+</td>
258 <td class="center">1.6</td>
259 <td class="center">A</td>
264 <td>Win 98+ / OSX.1+</td>
265 <td class="center">1.7</td>
266 <td class="center">A</td>
271 <td>Win 98+ / OSX.1+</td>
272 <td class="center">1.8</td>
273 <td class="center">A</td>
277 <td>Seamonkey 1.1</td>
278 <td>Win 98+ / OSX.2+</td>
279 <td class="center">1.8</td>
280 <td class="center">A</td>
284 <td>Epiphany 2.20</td>
286 <td class="center">1.8</td>
287 <td class="center">A</td>
293 <td class="center">125.5</td>
294 <td class="center">A</td>
300 <td class="center">312.8</td>
301 <td class="center">A</td>
307 <td class="center">419.3</td>
308 <td class="center">A</td>
314 <td class="center">522.1</td>
315 <td class="center">A</td>
321 <td class="center">420</td>
322 <td class="center">A</td>
326 <td>iPod Touch / iPhone</td>
328 <td class="center">420.1</td>
329 <td class="center">A</td>
335 <td class="center">413</td>
336 <td class="center">A</td>
341 <td>Win 95+ / OSX.1+</td>
342 <td class="center">-</td>
343 <td class="center">A</td>
348 <td>Win 95+ / OSX.2+</td>
349 <td class="center">-</td>
350 <td class="center">A</td>
355 <td>Win 95+ / OSX.2+</td>
356 <td class="center">-</td>
357 <td class="center">A</td>
362 <td>Win 95+ / OSX.2+</td>
363 <td class="center">-</td>
364 <td class="center">A</td>
369 <td>Win 95+ / OSX.3+</td>
370 <td class="center">-</td>
371 <td class="center">A</td>
376 <td>Win 88+ / OSX.3+</td>
377 <td class="center">-</td>
378 <td class="center">A</td>
383 <td>Win 88+ / OSX.3+</td>
384 <td class="center">-</td>
385 <td class="center">A</td>
389 <td>Opera for Wii</td>
391 <td class="center">-</td>
392 <td class="center">A</td>
398 <td class="center">-</td>
399 <td class="center">A</td>
403 <td>Nintendo DS browser</td>
405 <td class="center">8.5</td>
406 <td class="center">C/A<sup>1</sup></td>
410 <td>Konqureror 3.1</td>
412 <td class="center">3.1</td>
413 <td class="center">C</td>
417 <td>Konqureror 3.3</td>
419 <td class="center">3.3</td>
420 <td class="center">A</td>
424 <td>Konqureror 3.5</td>
426 <td class="center">3.5</td>
427 <td class="center">A</td>
431 <td>Internet Explorer 4.5</td>
433 <td class="center">-</td>
434 <td class="center">X</td>
438 <td>Internet Explorer 5.1</td>
439 <td>Mac OS 7.6-9</td>
440 <td class="center">1</td>
441 <td class="center">C</td>
445 <td>Internet Explorer 5.2</td>
447 <td class="center">1</td>
448 <td class="center">C</td>
452 <td>NetFront 3.1</td>
453 <td>Embedded devices</td>
454 <td class="center">-</td>
455 <td class="center">C</td>
459 <td>NetFront 3.4</td>
460 <td>Embedded devices</td>
461 <td class="center">-</td>
462 <td class="center">A</td>
467 <td>Embedded devices</td>
468 <td class="center">-</td>
469 <td class="center">X</td>
475 <td class="center">-</td>
476 <td class="center">X</td>
482 <td class="center">-</td>
483 <td class="center">X</td>
488 <td>Windows Mobile 6</td>
489 <td class="center">-</td>
490 <td class="center">C</td>
496 <td class="center">-</td>
497 <td class="center">C</td>
500 <td>Other browsers</td>
503 <td class="center">-</td>
504 <td class="center">U</td>
509 <div class="spacer"></div>
512 <h1>Initialisation code</h1>
513 <pre>function fnMessage ( sMesg )
515 var n = document.getElementById('info');
516 n.innerHTML += sMesg+"<br>";
517 n.scrollTop = n.scrollHeight;
520 $(document).ready( function () {
521 var keys = new KeyTable();
523 /* Focus handler for all cells in last column */
524 keys.event.focus( 4, null, function( nNode, x, y ) {
525 fnMessage( "Cell "+x+","+y+" focused ('live' event - column)" );
528 /* Focus handler for all cells in 8th row */
529 keys.event.focus( null, 7, function( nNode, x, y ) {
530 fnMessage( "Cell "+x+","+y+" focused ('live' event - row)" );
533 /* Focus using coords. */
534 keys.event.focus( 1, 0, function( nNode ) {
535 keys.event.remove.focus( nNode );
536 fnMessage( "Cell 1,0 focus - this event has now been removed" );
539 keys.event.focus( 1, 3, function() {
540 fnMessage( "Cell 1,3 focus" );
543 /* focus with a node */
544 keys.event.focus( $('#example tbody tr:eq(2) td:eq(0)')[0], function() {
545 fnMessage( "Cell 0,2 focus" );
548 /* Blur using a node */
549 keys.event.blur( $('#example tbody tr:eq(1) td:eq(2)')[0], function() {
550 fnMessage( "Cell 1,2 blur" );
553 /* Blur using coords */
554 keys.event.blur( 2, 4, function() {
555 fnMessage( "Cell 2,4 blur" );
559 keys.event.action( 2, 2, function( nNode ) {
560 fnMessage( "Cell 2,2 action" );
561 if ( nNode.style.fontWeight == "" || nNode.style.fontWeight == "normal" ) {
562 nNode.style.fontWeight = "bold";
564 nNode.style.fontWeight = "normal";
568 keys.event.action( 2, 5, function( nNode ) {
569 fnMessage( "Cell 2,5 action" );
570 if ( nNode.style.fontStyle == "" ) {
571 nNode.style.fontStyle = "italic";
573 nNode.style.fontStyle = "";
579 <h1>Other examples</h1>
581 <li><a href="index.html">Basic usage</a></li>
582 <li><a href="editing.html">Editing a table</a></li>
583 <li><a href="form.html">Integration with an HTML form</a></li>
584 <li><a href="datatable.html">Integration with DataTables</a></li>
585 <li><a href="datatable_scrolling.html">Using KeyTable with scrolling in DataTables</a></li>
588 <div id="footer" style="text-align:center;">
589 <span style="font-size:10px;">
590 KeyTable © Allan Jardine 2009.<br>
591 Information in the table © <a href="http://www.u4eatech.com">U4EA Technologies</a> 2007-2009.</span>