diff -u --exclude '*~' --exclude '*#' --new-file orig/keys_api/keys_api.js keys_api/keys_api.js
--- orig/keys_api/keys_api.js	2008-04-11 16:36:25.000000000 +0000
+++ keys_api/keys_api.js	2008-07-16 18:49:18.000000000 +0000
@@ -5,8 +5,8 @@
     
   });
   
-  function setDomain() {
-    $("#edit-domain").val(window.location.host);
+  function setDomain(url) {
+    $("#edit-domain").val(url);
   }
   
   function deleteItem(item) {
diff -u --exclude '*~' --exclude '*#' --new-file orig/keys_api/keys_api.module keys_api/keys_api.module
--- orig/keys_api/keys_api.module	2008-06-22 02:12:08.000000000 +0000
+++ keys_api/keys_api.module	2008-07-16 19:11:28.000000000 +0000
@@ -1,6 +1,8 @@
 <?php
 // $Id: keys_api.module,v 1.5 2008/06/22 02:12:08 greenskin Exp $
 
+require_once(drupal_get_path('module', 'keys_api') .'/keys_helper.inc');
+
 /**
  * Implementation of hook_help().
  */
@@ -29,6 +31,7 @@
     $items[] = array(
       'path' => 'admin/settings/keys',
       'title' => t('Keys'),
+      'description' => t('Configure API keys'),
       'callback' => 'drupal_get_form',
       'callback arguments' => array('keys_manage_settings'),
       'access' => user_access('administer keys'),
@@ -66,14 +69,14 @@
   );
   $form['domain'] = array(
     '#type' => 'textfield',
-    '#title' => t("Domain Name"),
-    '#description' => t("The domain name the supplied key is registered for. For example: example.com, sub.example.com, localhost, localhost:9000."),
+    '#title' => t("URL Prefix"),
+    '#description' => t("The URL prefix the supplied key is registered for. For example: http://example.com/, https://sub.example.com/drupal, http://localhost:9000/"),
     '#required' => TRUE,
   );
   $form['set_domain'] = array(
     '#type' => 'button',
-    '#value' => t("Set Domain to Current"),
-    '#attributes' => array('onclick' => 'setDomain(); return false;'),
+    '#value' => t("Set URL Prefix to Current"),
+    '#attributes' => array('onclick' => "setDomain('" . keys_api_get_url() . "'); return false;"),
   );
   $form['service'] = array(
     '#type' => 'select',
@@ -170,7 +173,9 @@
  * @return
  *   The API Key.
  */
-function keys_api_get_key($service, $domain) {
+function keys_api_get_key($service, $domain='') {
+  if ($domain == '')
+    $domain = keys_api_get_url();
   $result = db_result(db_query("SELECT api_key FROM {keys_manage} WHERE domain_name = '%s' AND service = '%s'", $domain, $service));
   $key = $result;
   if ($key == NULL) {
diff -u --exclude '*~' --exclude '*#' --new-file orig/keys_api/keys_helper.inc keys_api/keys_helper.inc
--- orig/keys_api/keys_helper.inc	1970-01-01 00:00:00.000000000 +0000
+++ keys_api/keys_helper.inc	2008-07-16 17:17:02.000000000 +0000
@@ -0,0 +1,14 @@
+<?php
+
+function keys_api_get_url() {
+  $proto = $_SERVER['HTTPS'] ? 'https' : 'http';
+  $url = $proto."://".$_SERVER['HTTP_HOST'];
+  $port = $_SERVER['SERVER_PORT'];
+  if (($proto == 'http' && $port != 80) || ($proto == 'https' && $port != 443)) {
+    $url .= ":$port";
+  }
+  $url .= base_path();
+  return $url;
+}
+
+?>
