#1 2015-08-28 10:14:32

Registered: 2015-04-21
Posts: 64

KeyDown event? Checking user's inputs on keyboard (and mouse click)


In certain circumstances I have to survey the inputs from the keyboard, means to check pressed keys. I realise this by adding the code

   <div id="action"></div>
   <script type="text/javascript">
      document.onkeydown = function(event) {
       var actionBox = document.getElementById('action');
       window.App.RootScope.KeyPressed = event.keyCode;
       return event.returnValue;

... into index.html. But until now I don´t find a way to implement this function directly in AppBuilder.

Thanks for your help


#2 2015-08-28 11:04:12

From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,661

Re: KeyDown event? Checking user's inputs on keyboard (and mouse click)

Hello Walter,

The above code look well except for the "document.getElementById('action')", which maybe cause an error if the element "action" doesn't exists. On the other hand, try to leave the "index.html" without changes, since this file is generated automatically by the program in every debug/build operation. Then you can use a separated Javascript to do something like that.

Update your App Builder copy because I update it in order to add the KeyUp and KeyDown events for all Input controls, Textarea and Typeahead controls. You can use such events like others in App Builder, and remember the variable "Event" of the control contains the information about the event, then in the case of the KeyUp and KeyDown events, for example:

// Log the pressed key code
Console "[Input1.Event.keyCode]" "info"


Board footer

Powered by FluxBB

Copyright ©2018 DecSoft. All rights reserved.