I have this code so far, but I can not figure out how to input the coordinates through a mouse click instead of the code below. I am trying to create a temporary layer of a point from a mouse click. Everything seems to work except for that I can not figure the coordinates out. I am also still very new to PyQGIS.
vl = QgsVectorLayer("Point", "POI", "memory")
from qgis.PyQt.QtCore import QVariant
pr = vl.dataProvider()
pr.addAttributes([QgsField("ID", QVariant.String)])
vl.updateFields()
f = QgsFeature()
f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(10,10)))
f.setAttributes(["1"])
pr.addFeature(f)
vl.updateExtents()
QgsProject.instance().addMapLayer(vl)
from qgis.PyQt.QtCore import QVariant
vl = QgsVectorLayer("Point", "POI", "memory")
pr = vl.dataProvider()
pr.addAttributes([QgsField("ID", QVariant.String)])
vl.updateFields()
f = QgsFeature()
f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(10,10)))
f.setAttributes(["1"])
pr.addFeature(f)
vl.updateExtents()
QgsProject.instance().addMapLayer(vl)