Envira Gallery Documentation

Documentation, Reference Materials and Tutorials for Envira Gallery

How to Disable Keyboard and Mousewheel Navigation

Disabling keyboard and mousewheel navigation means prevent you from using the keyboard keys such as arrow keys and mouse scroll wheel to change or scroll the gallery’s image.

With Envira Gallery, you can achieve this using simple code snippets. This guide will show you how!

Heads up!

This article contains PHP, CSS, and/or JavaScript to customize our plugin. We offer this code as a courtesy but don’t provide support for additional code customizations or 3rd party development.

To disable keyboard and mousewheel navigation, just add the following code to your site.

If you need help adding custom code to your site, please check out our guide on adding custom PHP or JavaScript to your site.

/* Disable Keyboard and Mousewheel Navigation
* 
* @link https://enviragallery.com/docs/how-to-disable-keyboard-and-mousewheel-navigation/
*/

// Disable for Albums
add_filter( 'envira_albums_pre_data', 'my_envira_album_pre_data', 10, 2 );
function my_envira_album_pre_data( $data, $album_id ) {
$data['config']['keyboard'] = 0; // 0 for disable, 1 to enable
$data['config']['mousewheel'] = false; // false for disable, true to enable
return $data;
}

// Disable for Galleries
add_filter( 'envira_gallery_pre_data', 'my_envira_gallery_pre_data', 10, 2 );
function my_envira_gallery_pre_data( $data, $gallery_id ) {
$data['config']['keyboard'] = 0; // 0 for disable, 1 to enable
$data['config']['mousewheel'] = false; // false for disable, true to enable
return $data;
}

After adding the code, check your Envira Gallery to ensure keyboard and mousewheel navigation are disabled as expected.

Disable Keyboard and Mouse Navigation

That’s it! Would you like to extend Envira further? Check out our tutorial on how to Display Adsense Ads in Lightbox.