Earth Engine sta introducendo
livelli di quota non commerciali per salvaguardare le risorse di calcolo condivise e garantire prestazioni affidabili per tutti. Tutti i progetti non commerciali dovranno selezionare un livello di quota entro il
27 aprile 2026, altrimenti verrà utilizzato il livello Community per impostazione predefinita. Le quote di livello entreranno in vigore per tutti i progetti (indipendentemente dalla data di selezione del livello) il
27 aprile 2026.
Scopri di più.
ui.root.setKeyHandler
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Imposta un gestore di eventi keydown nel pannello principale con una chiave non predefinita. Il gestore viene attivato una sola volta quando un utente preme il comando della chiave associata. La stessa chiave verrà associata al gestore più recente impostato.
| Utilizzo | Resi |
|---|
ui.root.setKeyHandler(keyCode, handler, description) | |
| Argomento | Tipo | Dettagli |
|---|
keyCode | List[ui.Key]|ui.Key | Un codice chiave o un array di codici chiave. Ad esempio, ui.Key.A o [ui.Key.SHIFT, ui.Key.A]. |
handler | Funzione | Il gestore per il comando della chiave. |
description | Stringa, facoltativa | Una breve descrizione che spiega questo comando della chiave. La descrizione sarà visibile nel menu Scorciatoie. |
Esempi
Editor di codice (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');
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2026-03-27 UTC.
[null,null,["Ultimo aggiornamento 2026-03-27 UTC."],[],["The `setKeyHandler` function binds a key command to a handler function on the root panel. It accepts a key code (or array of codes), a handler function, and an optional description. When the bound key is pressed, the handler is executed once. Only the most recently assigned handler for a specific key will be triggered. Key codes can be individual (e.g., `ui.Key.A`) or combined (e.g., `[ui.Key.SHIFT, ui.Key.A]`). The description is used in the Shortcuts Menu.\n"]]