Hiding ControlP5 controller

Is it possible to hide a controlP5 say with a key press or boolean within a key press?

Am asking this because a controlP5 controller eg: slider, gets ‘created’ in setup() at the beginning and so there is no access to it later on, to control it via key presses or so it seems.

You can hide it as part of the creation process, but am not sure if it’s possible while a sketch is running.

Would anyone be kind enough to point me in the right direction? It’s more of a theory question at the moment… don’t have any specific code to share. Thanks!

1 Like

Try to use :

  • controlP5.Controller : Slider hide()

  • controlP5.Controller : Slider show()

import controlP5.*;

ControlP5 cp5;
float sliderValue = 0;

void setup() {
  cp5 = new ControlP5(this);
  // add a horizontal sliders, the value of this slider will be linked
  // to variable 'sliderValue' 

void draw() {

void keyPressed(){

Thanks Josephh… this worked perfectly. Was trying this out and was able to adapt to my code.

My mistake was that I was adding hide() to individual sliders/controllers rather than ‘cp5’ itself. Makes perfect sense. Thanks a ton for clearing that up! :slight_smile:

1 Like

Just so you know – this isn’t true. For access, you can create a named controller object and then add it to your ControlP5 for direct access. Or (more commonly) you can use getController() to retrieve a named controller, then manipulate it – for example, calling show/hide.

From the ControllerBasics.pde demo sketch:


  // change individual settings for a controller
1 Like

Thanks @jeremydouglass that’s very interesting! :slight_smile:

1 Like