43
Views
10
Comments
Solved
How do I operate the program from the keyboard, not the mouse?

Hello friends, I am a beginner in Outystems and I need some help.

How do I make it so that when I dial the number 1 for example, the registration menu is clicked, and so on.

How do I operate the program from the keyboard, not the mouse? It's possible?


Thanks for your help :)

Acionandopeloteclado.jpg

Rank: #94
Solution

Tom Nogueira wrote:

Hello Rui!

Thanks for response:)

I am in Tradicional Web,  is the same process ?

Thanks again. 

Hello Tom,

For Traditional Web Applications, it is very different :)

In this scenario, you will need to put your JavaScript code in the Preparation of your screen, using RunJavaScript action (from HTTPRequestHandler extension). Also, you need to use FakeNotifyWidget Block from RichWidgets module directly in your screen.

Your script should incluse this function:

"OsNotifyWidget('"+ <YourFakeNotifyWidget>.Id +"', '<Message>')"


Please consider this post from MVP Nordin Ahdi where he provides an excellent explanation about this topic and how it should be implemented.


Also, I did a sample for you and your JavaScript code should be something like:

"
$(document).ready(function() {
    $(window).on('keydown', function(event) {
        if (event.keyCode === 49 || event.keyCode === 97) {
            OsNotifyWidget('"+ MyFakeNotifyWidget.Id +"', 'key1');
        }
        if (event.keyCode === 50 || event.keyCode === 98) {
            OsNotifyWidget('"+ MyFakeNotifyWidget.Id +"', 'key2');
        }
        if (event.keyCode === 51 || event.keyCode === 99) {
            OsNotifyWidget('"+ MyFakeNotifyWidget.Id +"', 'key3');
        }
        if (event.keyCode === 52 || event.keyCode === 100) {
            OsNotifyWidget('"+ MyFakeNotifyWidget.Id +"', 'key4');
        }
        if (event.keyCode === 53 || event.keyCode === 101) {
            OsNotifyWidget('"+ MyFakeNotifyWidget.Id +"', 'key5');
        }
        if (event.keyCode === 54 || event.keyCode === 102) {
            OsNotifyWidget('"+ MyFakeNotifyWidget.Id +"', 'key6');
        }
    });
});"


Please refer to attached OML file with an example for Traditional Web of a client action beeing triggered by clicking in your keys (from 1 to 6).


Hope it helps you!


Kind regards,

Rui Barradas

TriggerEnterKey.oml

Rank: #94

Hello Tom,

Hope you are doing well!

You should be able to do it using JavaScript :)


Are you using a Traditional Web Application or a Reactive Web Application?

If it is a Reactive Web Application, you can put a JavaScript widget inside the OnReady event of your screen in order to detect when the user presses those keys:

document.addEventListener("keyup", function(event) {
  // Number 49/97 is the "1" key on the keyboard
  if (event.keyCode === 49 || event.keyCode === 97) {
      //Run your code for key "1"
  }
  // Number 50/98 is the "2" key on the keyboard
  if (event.keyCode === 50 || event.keyCode === 98) {
      //Run your code for key "2"
  }
  // Number 51/99 is the "3" key on the keyboard
  if (event.keyCode === 51 || event.keyCode === 99) {
      //Run your code for key "3"
  }
  // Number 52/100 is the "4" key on the keyboard
  if (event.keyCode === 52 || event.keyCode === 100) {
      //Run your code for key "4"
  }
  // Number 53/101 is the "5" key on the keyboard
  if (event.keyCode === 53 || event.keyCode === 101) {
      //Run your code for key "5"
  }
  // Number 54/102 is the "6" key on the keyboard
  if (event.keyCode === 54 || event.keyCode === 102) {
      //Run your code for key "6"
  }
});


Please refer to attached OML file with an example of a client action beeing triggered by clicking in your keys (from 1 to 6).


Hope that this helps you!


Kind regards,

Rui Barradas

TriggerEnterKey.oml

Rank: #8922

Hello Rui!

Thanks for response:)

I am in Tradicional Web,  is the same process ?

Thanks again. 

Hello Tom,

For traditional web you can use this forge component. It's still on P10 but it can be easily upgraded.

Rank: #8922

I will try and post results, thanks in advance for your help.

And I will read the post MVP too :) 

Rank: #94

Sure thing Tom :)

Let me know after about your conclusions.


Kind regards,

Rui Barradas

Rank: #94

Hello Tom,

Did you manage to solve your issue? :)


Kind regards,

Rui Barradas

Rank: #94

You're most welcome Tom :)

Happy coding!


Kind regards,

Rui Barradas