A simple question I am trying to detect the enter key of my keyboard by pressing it but it does not work. this is the code I use:
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5 import QtCore
from PyQt5 import Qt
class Principal(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
def keyPressEvent(self,event):
if event.key() == QtCore.Qt.Key_Enter:
print("pressed")
event.accept()
app = QApplication([])
p = Principal()
p.show()
app.exec_()