diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index eb2e78b5c..97e3d3e88 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -1745,17 +1745,18 @@ QVariant ScribusMainWindow::inputMethodQuery ( Qt::InputMethodQuery query ) cons
 //AV -> CanvasMode
 void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 {
-	QList<QMdiSubWindow *> windows;
-	QMdiSubWindow* w = nullptr;
+	if (!HaveDoc)
+		m_keyrep = true;
+		return;
+
 	int kk = k->key();
-	if (HaveDoc)
+
+	if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift))
 	{
-		if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift))
-		{
-			view->setCursor(IconManager::instance().loadCursor("lupezm.png"));
-			return;
-		}
+		view->setCursor(IconManager::instance().loadCursor("lupezm.png"));
+		return;
 	}
+
 	if (m_keyrep)
 		return;
 	m_keyrep = true;
@@ -1767,7 +1768,7 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 	if (k->modifiers() & Qt::AltModifier)
 		keyMod |= Qt::ALT;
 	//User presses escape and we have a doc open, and we have an item selected
-	if ((kk == Qt::Key_Escape) && (HaveDoc))
+	if (kk == Qt::Key_Escape)
 	{
 		m_keyrep = false;
 		PageItem *currItem;
@@ -1831,7 +1832,7 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 	}
 	Qt::KeyboardModifiers buttonModifiers = k->modifiers();
 	/**If we have a doc and we are not changing the page or zoom level in the status bar */
-	if ((HaveDoc) && (!zoomSpinBox->hasFocus()) && (!pageSelector->hasFocus()))
+	if (!zoomSpinBox->hasFocus() && !pageSelector->hasFocus())
 	{
 		//Show our context menu
 		if (actionManager->compareKeySeqToShortcut(kk, buttonModifiers, "viewShowContextMenu"))
@@ -1880,7 +1881,6 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 				else
 					view->requestMode(modePanning);
 				return;
-				break;
 			case Qt::Key_PageUp:
 				if (doc->masterPageMode() || doc->symbolEditMode() || doc->inlineEditMode())
 					view->scrollBy(0, -m_prefsManager.mouseWheelJump());
@@ -1896,7 +1896,6 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 				}
 				m_keyrep = false;
 				return;
-				break;
 			case Qt::Key_PageDown:
 				if (doc->masterPageMode() || doc->symbolEditMode() || doc->inlineEditMode())
 					view->scrollBy(0, m_prefsManager.mouseWheelJump());
@@ -1912,32 +1911,28 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 				}
 				m_keyrep = false;
 				return;
-				break;
 			case Qt::Key_Left:
 				view->scrollBy(-wheelVal, 0);
 				m_keyrep = false;
 				return;
-				break;
 			case Qt::Key_Right:
 				view->scrollBy(wheelVal, 0);
 				m_keyrep = false;
 				return;
-				break;
 			case Qt::Key_Up:
 				view->scrollBy(0, -wheelVal);
 				m_keyrep = false;
 				return;
-				break;
 			case Qt::Key_Down:
 				view->scrollBy(0, wheelVal);
 				m_keyrep = false;
 				return;
-				break;
 			case Qt::Key_Tab:
 				if (buttonModifiers == Qt::ControlModifier)
 				{
 					m_keyrep = false;
-					windows = mdiArea->subWindowList();
+					auto windows = mdiArea->subWindowList();
+					QMdiSubWindow* w = nullptr;
 					if (windows.count() > 1)
 					{
 						for (int i = 0; i < static_cast<int>(windows.count()); ++i)
@@ -1976,15 +1971,16 @@ void ScribusMainWindow::keyPressEvent(QKeyEvent *k)
 
 void ScribusMainWindow::keyReleaseEvent(QKeyEvent *k)
 {
+	if (!HaveDoc)
+		return;
+
 	//Exit out of panning mode if Control is release while the right mouse button is pressed
-	if (HaveDoc)
-	{
-		if ((doc->appMode == modePanning) && (k->key() == Qt::Key_Control) && (QApplication::mouseButtons() & Qt::RightButton))
-			view->requestMode(modeNormal);
+	if ((doc->appMode == modePanning) && (k->key() == Qt::Key_Control) && (QApplication::mouseButtons() & Qt::RightButton))
+		view->requestMode(modeNormal);
+
+	if (doc->appMode == modeMagnifier)
+		view->setCursor(IconManager::instance().loadCursor("lupez.png"));
 
-		if (doc->appMode == modeMagnifier)
-			view->setCursor(IconManager::instance().loadCursor("lupez.png"));
-	}
 	if (k->isAutoRepeat() || !m__arrowKeyDown)
 		return;
 	switch (k->key())
@@ -1994,7 +1990,7 @@ void ScribusMainWindow::keyReleaseEvent(QKeyEvent *k)
 		case Qt::Key_Up:
 		case Qt::Key_Down:
 			m__arrowKeyDown = false;
-			if ((HaveDoc) && (!zoomSpinBox->hasFocus()) && (!pageSelector->hasFocus()))
+			if (!zoomSpinBox->hasFocus() && !pageSelector->hasFocus())
 			{
 				int docSelectionCount = doc->m_Selection->count();
 				if ((docSelectionCount != 0) && (doc->appMode == modeEditClip) && (doc->nodeEdit.hasNodeSelected()))
