diff --git a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
index 405dece3bbadb4c49e890a3decc199a7ee6c1c28..cc91fbb42a8bf57bbd5fd716e4af1c00543452bf 100644
--- a/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
+++ b/examples/quick/dialogs/systemdialogs/CustomDialogs.qml
@@ -135,6 +135,7 @@ Item {
         id: filledDialog
         modality: dialogModal.checked ? Qt.WindowModal : Qt.NonModal
         title: customizeTitle.checked ? windowTitleField.text : "Customized content"
+        onRejected: lastChosen.text = "Rejected"
         contentItem: Rectangle {
             color: "lightskyblue"
             implicitWidth: 400
@@ -144,8 +145,8 @@ Item {
                 color: "navy"
                 anchors.centerIn: parent
             }
-            focus: true
-            Keys.onEscapePressed: filledDialog.close()
+            Keys.onEscapePressed: filledDialog.reject()
+            Keys.onBackPressed: filledDialog.reject() // especially necessary on Android
         }
     }