What I'm doing wrong, this code works onTap but not on key or keyPressed??
import Toybox.Application;
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.WatchUi;
var val;
class Delegate extends WatchUi.BehaviorDelegate {
function initialize() {
BehaviorDelegate.initialize();
val = false;
}
public function mode() as Boolean {
val = !val;
WatchUi.requestUpdate();
return true;
}
public function onTap(evt as ClickEvent) as Boolean {
return mode();
}
public function onKeyPressed(evt as KeyEvent) as Boolean {
if (evt.getKey() == WatchUi.KEY_ENTER) {
return mode();
}
return true;
}
}