Does anyone know why these event codes run twice?

E.g. I am using a cookie to keep track of [Ctrl] + [Shift] + [F] by incrementing a variable once everytime it is used. However the code for it runs twice and thus the variable is never odd as it always increments by two.

It's the same for the other events, such as [Ctrl] + [Shift] + [S], it runs twice. This was not occuring when I first inserted the cookie code last week. I have read about "bubbling" but I cannot seem to stop the code running a second time.

EDIT: Internet Explorer (6+) is only browser code needs to work in.

document.addEvent('keydown', function(event) {

	var event = new Event(event);

  	if (event.key == 'f' && event.control && event.shift) {

		// We attempt to set footerCookie
		// If cookie does not already exist, it will be set to null / false
		var footerCookie = Cookie.get('footerCookie');
		var footerCookieCount = 0;
		// If no cookie is set, we set the variable, footerCookieCount, to zero
		if (footerCookie == null) {
			footerCookieCount = 0
		// If a cookie is set, we assign its value to the variable, footerCookieCount
		else {
			footerCookieCount = Cookie.get('footerCookie');

		// Increment the variable, footerCookieCount.
		// Odd numbers mean the customer_glance is set to active
		/*	http://docs111.mootools.net/Remote/Cookie.js#Cookie.Properties	
			Method Cookie.set()
			key	the key (name) for the cookie
			value	the value to set, cannot contain semicolons
			options	an object representing the Cookie options.  See Options below.  Default values are stored in Cookie.options.
			domain	the domain the Cookie belongs to.  If you want to share the cookie with pages located on a different domain, you have to set this value.  Defaults to the current domain.
			path		the path the Cookie belongs to.  If you want to share the cookie with pages located in a different path, you have to set this value, for example to “/” to share the cookie with all pages on the domain.  Defaults to the current path.
			duration	the duration of the Cookie before it expires, in days.  If set to false or 0, the cookie will be a session cookie that expires when the browser is closed.  This is default.
			secure	Stored cookie information can be accessed only from a secure environment.
			Returns	An object with the options, the key and the value.  You can give it as first parameter to Cookie.remove.
		// We create / set cookie
		// @ param cookie name
		// @ param cookie value
		// @ param path: use '/' to ensure cookie lasts for all sub-domains
		// default expiry of session / browser window open
		footerCookie = Cookie.set('footerCookie', footerCookieCount, {path: '/'});


    if (event.key == 's' && event.control && event.shift) {

		if ($('edit_search') != null) {

			if($('edit_search').hasClass('active')) {
				if ($('round1') != null) {
    if (event.key == 'n' && event.control && event.shift) {
   		if ($('sub_crumbs').hasClass('active')) {
				display: 'block'
				display: 'none'
		else {
				display: 'block'
				display: 'none'

Edited by mairtinomarta: n/a

8 Years
Discussion Span
Last Post by mairtinomarta
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.