Gambas Documentation - /comp/gb.qt4/key/alt

/comp/gb.qt4/key/alt

# Key.Alt (gb.qt4)

Static Property Read Alt As Boolean

Returns if the `ALT` key is pressed.

This is inside ..._KeyPress or ..._KeyRelease Events.

Keys may have functions assigned to them by OS or other programs; you could close/... your program/other programs/system.

### Examples

    ' Needing a Button1; with the focus on it( Use the Tab key).
    ' can cut and Paste this  example.

    PUBLIC SUB Button1_KeyPress()
      IF Key.Alt THEN
        Button1.Text = " True " & CString(Time)
      ELSE
        Button1.Text = " False " & CString(Time)
      ENDIF
    END

    PUBLIC SUB Form_KeyPress()
    ' KeyPress with Control Key event will often pass through to this Form event.
      DIM altSet AS Boolean
      TRY altSet = Key.Alt
      altSet = IIf( ERROR , FALSE, altSet)
      IF altSet THEN
        ME.Text = CString(Time) & " True: Control key is being held down"
      ELSE
        ME.Text = CString(Time) & " False: Control key was not held down"
      ENDIF
    END

### See also

- KeyPress

- KeyRelease