Showing results for 
Search instead for 
Did you mean: 

Using Hotkeys Api and use switch method to switch between the Shortcuts in SAPUI5.

0 Kudos

Hello everyone,

I try to use Hotkey Api file as in this blog Hotkey Api and have some questions. First Api file called Hotkey.js. How can I call the hotkeys which are located in this file in controller file to use it there?

second question: should I use switch method instead of using if condition each time and to make the code more tidy? And how to use switch method hier?

Thank you


var table = this.byId("table");
				onkeydown: function(oEvent) {
					var selectedCheckbox = false;
					var items = table.getItems();

					// Check if any checkbox is selected
					for (var i = 0; i < items.length; i++) {
						var checkbox = items[i].getCells()[0]; // Assuming the checkbox is in the first column
						if (checkbox.getSelected()) {
							selectedCheckbox = true;


					// Execute the code only if a checkbox is selected
					if (selectedCheckbox) {
						if (oEvent.keyCode === 46) {

						if (oEvent.ctrlKey || oEvent.metaKey) {
							if (oEvent.code === "KeyC") { // Check if the pressed key is 'C'
							if (oEvent.code === "KeyV") {




Accepted Solutions (0)

Answers (0)