cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to bind a key listener to UI5's sap.m.Dialog?

0 Kudos

There is nothing in the events list which says you can but is there any other way to add an event listener to respond to key presses when the dialog is open? https://sapui5.hana.ondemand.com/#/api/sap.m.Dialog/events/Summary

Accepted Solutions (0)

Answers (2)

Answers (2)

maheshpalavalli
Active Contributor
0 Kudos

Hi Ikim SS,

you can do like Nabheet Madan has mentioned or you can use the below blog to acheive your requirement.

https://blogs.sap.com/2017/06/14/hotkeys-keyboard-shortcuts-in-sap-ui5-using-open-source-plugin/

BR,

Mahesh

nabheetscn
Active Contributor
0 Kudos

Hello

You can use the windows listener like below.

window.onkeyup = function(event) {
console.log("kep pressed is"+event.keyCode);
}

0 Kudos

But if you bind the listener to the window then how will you know that you are on that particular dialog?

nabheetscn
Active Contributor
0 Kudos

You can check if the dialog window is opened inside using id and decide accordingly.

Nabheet