HeaderPane
Main
Hide
Share Link
Print

Keyboard Interface

The keys below work in a dialog, where the dialog manager moves the input focus with Tab and Shift+Tab and uses Enter and Escape for its default and Cancel buttons, and in any other window. The controls take the keys they need from the dialog manager (WM_GETDLGCODE), so a key listed here reaches the control even in a dialog, unless it says otherwise.

Field

With segment editing (SFTDATE_EDIT_SEGMENTS, the default):

KeyAction
DigitsType the number of the part being edited, also digits of other scripts such as Arabic-Indic and full-width digits (see Editing).
LettersChoose a month shown as a name by its first letters, and AM or PM by the first letter of the designator.
Separator characters (/ . - : , space)Complete the part being edited and move to the next part. The culture's date and time separators and the literal characters of the format are separators as well.
Up, DownChange the part being edited by one.
+ (main keyboard or numeric keypad), - (numeric keypad)Change the part being edited by one.
Left, RightMove to the previous or next part (the next or previous part with the right-to-left layout).
Home, EndMove to the first or last part.
Tab, Shift+TabMove to the next or previous part; from the last or the first part, to the next or previous control.
Delete, BackspaceEmpty the part being edited, in a field that allows empty values (SftDate_SetAllowEmpty).
SpaceCheck or clear the check box (SftDate_SetShowCheckBox). Without a check box, Space is a separator.
EnterComplete a value that has empty parts. Otherwise Enter goes to the dialog's default button.
EscapeGoes to the dialog's Cancel button while the dropdown is closed.
Ctrl+C, Ctrl+InsertCopy the formatted value.
Ctrl+V, Shift+InsertPaste a text and parse it.
F4Open the dropdown, or close it without changing the value.
Alt+Down, Alt+UpOpen the dropdown, or close it and accept the date or time.

While the check box is cleared, the keys that edit the value are ignored. Space checks the box again, and the dropdown keys still work; choosing a date in the dropdown checks the box.

With free-form editing (SFTDATE_EDIT_FREEFORM), the field shows a text box:

KeyAction
Characters, Left, Right, Home, End, Delete, Backspace, Ctrl+C, Ctrl+V and the other keys of a text boxEdit the text. Space is typed into the text, also in a field with a check box.
EnterParse the text and accept the value; then Enter goes to the dialog's default button.
EscapeRestore the text of the current value. When the text is unchanged, Escape goes to the dialog's Cancel button.
Up, DownAccept the text and change the value by one day, or by one minute in a field showing only a time.
Tab, Shift+TabMove to the next or previous control; the text is parsed when the field loses the input focus.
F4, Alt+Down, Alt+UpOpen or close the dropdown, as with segment editing.

While the dropdown is open, the keys go to the dropdown until a text is typed. After that, Space, Left, Right, Home and End edit the text, and Enter, Tab, F4, Alt+Down and Alt+Up close the dropdown and accept the typed text instead of the dropdown's selection.

Dropdown

The field keeps the input focus while the dropdown is open, and these keys go to the dropdown:

KeyAction
EnterAccept the date or time and close the dropdown. In a calendar without a time selection, the focused date is chosen; in range mode, a range whose last date was not chosen yet becomes a range of one day.
EscapeClose the dropdown without changing the value.
F4Close the dropdown without changing the value.
Alt+Up, Alt+DownAccept the date or time and close the dropdown.
Tab, Shift+TabSwitch between the calendar and the time selection. When the dropdown shows only one of them, accept the value, close the dropdown and move on as Tab and Shift+Tab do in the field.
SpaceIn the calendar, choose the focused date, as a click does. In the time selection, see below.
Arrow keys, Page Up, Page Down, Home, EndMove in the calendar or the time selection (see below). In the dropdown calendar of a single date, moving selects the focused date; the value changes when the dropdown is accepted.

Calendar

These keys work in an SftCalendar control and in the dropdown calendar of a field. In an SftCalendar control showing its smallest view, moving the focus selects the focused date, or starts a new range at it in range mode.

KeyAction
Left, RightMove to the previous or next day (month, year or decade in the larger views). The keys are swapped with the right-to-left layout.
Up, DownMove to the same day of the previous or next week (one row up or down in the larger views).
Page Up, Page DownMove to the same day of the previous or next month (the previous or next year in the year view, decade in the decade view and century in the century view).
Ctrl+Page Up, Ctrl+Page DownMove to the same day of the previous or next year (month view).
Home, EndMove to the first or last day of the month (the first or last month, year or decade of the period shown in the larger views).
Shift with the keys aboveExtend the range, in an SftCalendar control in range mode.
Ctrl+UpSwitch to the next larger view (year, decade, century).
Ctrl+DownSwitch to the next smaller view.
EnterSwitch to the next smaller view. In the smallest view, choose the date (NM_SFTDATE_DATEACTIVATED); in a dialog, Enter goes to the dialog's default button in the smallest view.
SpaceSwitch to the next smaller view; in the smallest view, choose the date (NM_SFTDATE_DATEACTIVATED).

Tab and Shift+Tab move the input focus from an SftCalendar control to the next or previous control.

Time List and Clock

KeyTime ListClock
Up, DownThe previous or next time.Up: the next value of the current step (hour, minutes or seconds). Down: the previous value.
Left, Right-Left: the previous value of the current step. Right: the next value.
Page Up, Page DownThe time one page up or down.-
Home, EndThe first or last time.-
SpaceChoose the time.Move to the next step; in the last step, choose the time.
EnterAccept the time and close the dropdown.Accept the time and close the dropdown.

Mouse

  • In a field, a click on a part edits it, a click on the check box toggles it, and a click on the dropdown button opens or closes the dropdown. Holding an up or down button down repeats the change. The mouse wheel changes the part being edited while a field with segment editing has the input focus, and scrolls the calendar or the time list under the mouse while the dropdown is open.
  • In a calendar, a click on a day selects it and chooses it (NM_SFTDATE_DATEACTIVATED); in an SftCalendar control in range mode, Shift+click and dragging select a range, and a click on a week number selects the week. A click on a title switches to the next larger view, a click on a month, a year or a decade to the next smaller one. Holding the previous or next button down keeps scrolling, and the mouse wheel scrolls the calendar. When the mouse rests on a special date with a tooltip, the tooltip is shown.

Handling Keys Yourself

The NM_SFTDATE_KEYDOWN notification is sent before a control handles a key. The SFTDATE_NMKEYDOWN structure holds the virtual key code (vk) and the modifier keys that are down (modifiers, a combination of SFTDATE_KEY_SHIFT, SFTDATE_KEY_CONTROL and SFTDATE_KEY_ALT). Setting fHandled to TRUE tells the control to ignore the key, including the character it would type.

case WM_NOTIFY:
    if (((LPNMHDR) lParam)->code == NM_SFTDATE_KEYDOWN) {
        LPSFTDATE_NMKEYDOWN lpKey = (LPSFTDATE_NMKEYDOWN) lParam;
        if (lpKey->vk == VK_F2 && lpKey->modifiers == 0) {
            SYSTEMTIME st;
            GetLocalTime(&st);
            SftDate_SetValue(lpKey->hdr.hwndFrom, &st);   /* F2 sets the current date and time */
            lpKey->fHandled = TRUE;
        }
        return TRUE;
    }
    break;

Last Updated 11/26/2026 - (email)
© 2026 Softel vdm, Inc.