Getting the Last Keystroke

The Vermont Views system saves, in a global variable, the value of the last key code read by ki(). To find out what this key code is, call the last key function, ki_last():

int ki_last()

This function returns a key code value.

ki_last() is useful for determining what to do based on the last thing the user did. For instance, you can specify that when the user presses Home twice, the virtual cursor goes to the top left corner of a window. If Home is pressed only once, the virtual cursor goes to the beginning of the current row.

if ( ki() == KEY_HOME) 

    cs_mv(ex_wnp->r, 0, ex_wnp);

if ( ki_last() == KEY_HOME)

    cs_mv(0, 0, ex_wnp);


Home Contents Previous Next