Earth Engine ขอแนะนำ
ระดับโควต้าที่ไม่ใช่เชิงพาณิชย์เพื่อปกป้องทรัพยากรการประมวลผลที่ใช้ร่วมกันและรับประกันประสิทธิภาพที่เชื่อถือได้สำหรับทุกคน โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดจะต้องเลือกระดับโควต้าภายในวันที่
27 เมษายน 2026 หรือจะใช้ระดับชุมชนโดยค่าเริ่มต้นก็ได้ โควต้าระดับจะมีผลกับโปรเจ็กต์ทั้งหมด (ไม่ว่าวันที่เลือกระดับจะเป็นวันใด) ในวันที่
27 เมษายน 2026 ดูข้อมูลเพิ่มเติม
ui.root.setKeyHandler
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
กำหนดตัวแฮนเดิลเหตุการณ์ keydown ให้กับแผงรูทด้วยคีย์ที่ไม่ได้กำหนดไว้ล่วงหน้า ตัวแฮนเดิลจะทำงานเพียงครั้งเดียวเมื่อผู้ใช้กดคำสั่งคีย์ที่ผูกไว้ ระบบจะผูกคีย์เดียวกันกับตัวแฮนเดิลล่าสุดที่ตั้งค่าไว้
| การใช้งาน | การคืนสินค้า |
|---|
ui.root.setKeyHandler(keyCode, handler, description) | |
| อาร์กิวเมนต์ | ประเภท | รายละเอียด |
|---|
keyCode | List[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');
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2026-03-27 UTC
[null,null,["อัปเดตล่าสุด 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"]]