void MyWidget::mousePressEvent(QMouseEvent *event) { if (event->modifiers() & Qt::ShiftModifier) { // do something special } else { // do normal mouse press code } }In this code example, the `modifiers()` function is used to determine if the `Shift` key is being pressed while the mouse button is clicked. If it is, a special action is taken, while if it is not, normal mouse press code is executed. This code uses the Qt package library, which is a C++ framework for building cross-platform applications.