Keyboard control via Javascript?

Bruce Bartlett shared this question 2 years ago
Needs Answer

Is there a way to listen for keyboard pushes via Javascript in Geogebra?

That would enable us to make simple games in GeoGebra.

For instance, in the "On update" Javascript code for a Point, is there any way of finding out if a key was pressed, and if so, which key?

I've tried eg.

function ggbOnInit() {
document.onkeydown = function(event) {
	var key_code = event.keyCode;
	if (key_code == 38)
		alert("Up arrow pressed");
in Geogebra 5 desktop app but I get the error "Document not defined".



© 2021 International GeoGebra Institute