Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Benoit Asselin http://www.ab-d.fr

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Fix double keypress with Safari

Fix a bug with the event keypress ( double keypress ... ) with Safari ( Mac OSX Tiger )
var v_fixDblKey = 0;
function fixDblKey() {
	if (v_fixDblKey != 0) {
		return true;
	} else {
		v_fixDblKey = setTimeout('v_fixDblKey = 0;', 10);
		return false;
	}
}

Sample
...
inputOnkeyup : function(event) {
	if (fixDblKey()) { return; }
	switch (event.keyCode) {
		case 38 : /* up */
			break
		case 40 : /* down */
			break;
		case 37 : /* left */
			break;
		case 39 : /* right */
			break;
		case  9 : /* tab */
			break;
		case 13 : /* enter */
			break;
	}
}
...
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS