# Manipulate Slider over discrete collection. Keyboard control.

I would like to create a Manipulate slider that iterates over a discrete set of items. Something like the following

Manipulate[u, CharacterRange["a","z"]]


produces a drop-down menu, which doesn't have a great interaction style. I must move the mouse back up to the top to get a new item, taking my eyes off the display back to the controls, rather than being able to just slide around without having to look at the controls too often.

Even better would be some kind of keyboard control that would let me left-and-right arrow my way through a collection. Then I'd never have to take my eyes off the target display. But that would be too intuitive [sarcasm].

-
Manipulate[u, {u, CharacterRange["a", "g"], ControlType -> Slider}] –  Kuba Jun 26 '13 at 19:43

EventHandler

DynamicModule[
{u = CharacterRange["a", "e"]},
EventHandler[
Framed[Dynamic@First@u],
{
{"MouseClicked", 1} :> (u = RotateLeft[u, 1]),
{"MouseClicked", 2} :> (u = RotateRight[u, 1])
}
]
]


But since second button is showing menu it is not very useful :) It is only a method so You can change event trigger.

You can also take a look at NotebookEventActions. Or CellEventActions:

CellEventActions

DynamicModule[{u = CharacterRange["a", "e"]},
CellPrint[
TextCell[Dynamic@First@u, "Output",
CellEventActions -> {"LeftArrowKeyDown" :> (u = RotateLeft[u, 1]),
"RightArrowKeyDown" :> (u = RotateRight[u, 1])}
]]];


This is what I like the most. But then You are not able to move selection cursor with arrows, not so much important but it depends what are You doing. :)

## Standard way

Slider

 Manipulate[u, {u, CharacterRange["a", "g"], ControlType -> Slider}]


Manipulator

Edit "StepLeftButton" does not work here how I expected. Anyone has an idea why? (I will remove it till explanation)

Manipulate[u, {u, CharacterRange["a", "g"], ControlType -> Manipulator,
AppearanceElements -> {"StepRightButton"}, Appearance -> "Open"}]


-
In the "Standard way" Manipulator, answer, the "StepLeftButton" doesn't seem to work :( –  Reb.Cabin Jun 26 '13 at 21:54
@Reb.Cabin You are right. I'm not sure why it is so... –  Kuba Jun 26 '13 at 22:01