ui.root.setKeyHandler

यह कुकी, रूट पैनल में keydown इवेंट हैंडलर सेट करती है. इसके लिए, पहले से तय नहीं की गई कुंजी का इस्तेमाल किया जाता है. जब कोई उपयोगकर्ता बाउंड की कमांड दबाता है, तब हैंडलर सिर्फ़ एक बार ट्रिगर होता है. यह कुंजी, हैंडलर के सबसे नए सेट से जुड़ी होगी.

इस्तेमालरिटर्न
ui.root.setKeyHandler(keyCode, handler, description)
आर्ग्यूमेंटटाइपविवरण
keyCodeList[ui.Key]|ui.Keyकुंजी कोड या कुंजी कोड की एक सरणी. उदाहरण के लिए, ui.Key.A या [ui.Key.SHIFT, ui.Key.A].
handlerफ़ंक्शनकुंजी के लिए हैंडलर कमांड.
descriptionस्ट्रिंग, ज़रूरी नहींकम शब्दों में इस कुंजी के काम के बारे में जानकारी. ब्यौरा, शॉर्टकट मेन्यू में दिखेगा.

उदाहरण

कोड एडिटर (JavaScript)

// Replace the default UI widgets with a few custom widgets.
// Print "Shift A" to the console when Shift+A is pressed.
ui.root.setKeyHandler(
  [ui.Key.SHIFT, ui.Key.A],
  function() {
    print('Shift A');
  },
  'A simple print'
);

// Create a solid black image.
var blackImage = ee.Image(1).visualize({palette: ['black']});

// Create a Layer object so we can easily manipulate its properties.
var blackLayer = ui.Map.Layer(blackImage, {}, 'Black Overlay', true);

// Add the layer to the Map.
Map.layers().add(blackLayer);

// Pressing the "b" key will toggle the layer on and off.
ui.root.setKeyHandler(ui.Key.B, function() {
  // Get the current visibility state.
  var isShown = blackLayer.getShown();

  // Set the visibility to the opposite of the current state.
  blackLayer.setShown(!isShown);

  // Print the status to the console.
  print('Black layer visible: ' + !isShown);
}, 'Toggle black layer');