Does ncurses have any support for touch screen computers? Will a touch screen trigger the same events in ncurses that a mouse does? For example, does tapping on a touch screen produce a "mouse click" event in ncurses?

I know that ncurses does support mouse input, so to the extent that a touchscreen can act like a mouse, it can interact with ncurses, I expect. So a tap is like a mouse click, a drag is the same in both.

But there is no scroll wheel with the touch screen, and no right click. Also, the touch screen potentially has gestures that a mouse does not.

  • It depends upon the display server (X11, Wayland, ....) and window manager (and terminal emulator) used by such computers. My feeling is that you should not use ncurses but a genuine GUI toolkit (e.g. Qt, GTK, ...) in your application Aug 30, 2018 at 8:54
  • Since your question already provides the information that an answer might be expected to provide, the intent is unclear. Aug 30, 2018 at 9:05
  • @ThomasDickey The intent is to determine to what extent ncurses will support a touchscreen. For example, does ncurses support gestures? If so, which gestures? If a person drags on a touchscreen will that be supported like a drag using a mouse? Does tapping on a touch screen produce the same effect as clicking with a mouse? Aug 30, 2018 at 9:15
  • But your question already answers that: it depends solely upon the device drivers and protocols used, and whether they "look" like a mouse. Aug 30, 2018 at 9:26

1 Answer 1


The mouse chapter of ncurses programming HOWTO might be useful reading.

The very first subchapter introduces all the mouse event masks: there is mouse position reporting, which includes x, y, and z coordinates, so one of them can be used to cover one scroll wheel. There are events for up to four buttons, and double- and triple-clicks for each of them. There are events for the use of Shift, Control and Alt keys as modifiers for click events. And that is all the information you can get through the ncurses mouse API.

But that document is more than 10 years old - perhaps it's not up to date?

Nope. Searching for word "touch" in /usr/include/ncurses.h produces several hits, but cross-referencing to the corresponding man pages indicates all of them refer to making decisions whether the content on screen requires refreshing or not. Nothing touchscreen-specific is available.

Even the latest version 6.1 brings no more advanced touchscreen support.

If you don't find what you're looking for after checking the sources I mentioned above, you can pretty conclusively determine that what you're seeking does not exist.

This is just my opinion, but it seems to me that multitouch and gestures would often require some graphics capability that would allow zooming and rotating some on-screen elements pretty freely, to just make it apparent that the gestures are doing something. A character-based display could be a poor fit for such an interface, so that's probably why nobody has made the effort to add specific touchscreen support yet.

But it sounds like you might have some novel ideas regarding touch user interfaces on text-based displays. You could perhaps prototype your ideas by having your demo application interface more directly with the actual touchscreen driver.

Once you have some idea on what kind of touchscreen UI elements actually work with text-bases displays (maybe recruit some university students to do a basic usability research project for you?), the next question will be: what kind of abstraction of touchscreen events would be most useful for implementing those?

It may turn out that there is no added value in passing the touchscreen events through ncurses itself: instead, you might find it appropriate to create a separate touch UI element library that connects to ncurses for display and the touchscreen driver for input. Who says you must use just one programming API at a time?

  • I am familiar with the basics of ncurses mouse support. The question is whether (and how much) that translates to touch screen support. Aug 30, 2018 at 12:35
  • That depends entirely on how the touchscreen driver translates them. It might translate one-, two- and three-finger taps as different mouse buttons if the touch hardware can provide that information. But that has nothing to do with ncurses.
    – telcoM
    Aug 30, 2018 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .