--- include/vlc_configuration.h	Sat Aug 25 14:42:43 2007
+++ include/vlc_configuration.h	Sat Aug 25 17:54:53 2007
@@ -323,8 +323,19 @@
 #define add_integer( name, value, p_callback, text, longtext, advc ) \
     add_int_inner( CONFIG_ITEM_INTEGER, name, text, longtext, advc, p_callback, value )
 
+#ifndef WIN32
 #define add_key( name, value, p_callback, text, longtext, advc ) \
     add_int_inner( CONFIG_ITEM_KEY, name, text, longtext, advc, p_callback, value )
+#else
+#define add_key( name, value, p_callback, text, longtext, advc ) \
+    add_int_inner( CONFIG_ITEM_KEY, name, text, longtext, advc, p_callback, value ); \
+    { \
+        char *psz_global_text = malloc( strlen( "Global " ) + strlen( text ) + 1 ); \
+        strcpy( psz_global_text, "Global " ); \
+        strcat( psz_global_text, text ); \
+        add_int_inner( CONFIG_ITEM_KEY, "global-" name, psz_global_text, longtext, advc, p_callback, KEY_UNSET ); \
+    }
+#endif
 
 #define add_integer_with_range( name, value, i_min, i_max, p_callback, text, longtext, advc ) \
     add_integer( name, value, p_callback, text, longtext, advc ); \
--- src/libvlc-common.c	Sat Aug 25 14:41:40 2007
+++ src/libvlc-common.c	Sat Aug 25 17:56:27 2007
@@ -793,9 +793,31 @@
      * Initialize hotkey handling
      */
     var_Create( p_libvlc, "key-pressed", VLC_VAR_INTEGER );
+#ifndef WIN32
     p_libvlc->p_hotkeys = malloc( libvlc_hotkeys_size );
     /* Do a copy (we don't need to modify the strings) */
     memcpy( p_libvlc->p_hotkeys, libvlc_hotkeys, libvlc_hotkeys_size );
+#else
+    p_libvlc->p_hotkeys = malloc( 2 * libvlc_hotkeys_size );
+    /* Do a copy (we don't need to modify the strings) */
+    memcpy( p_libvlc->p_hotkeys, libvlc_hotkeys, libvlc_hotkeys_size );
+
+    {
+        char *psz_global_action;
+        int i;
+
+        for( i = 0; p_libvlc->p_hotkeys[i].psz_action != NULL; i++ );
+        memcpy( &p_libvlc->p_hotkeys[i], libvlc_hotkeys, libvlc_hotkeys_size );
+
+        for( ; p_libvlc->p_hotkeys[i].psz_action != NULL; i++ )
+        {
+            psz_global_action = malloc( strlen( "global-" ) + strlen( p_libvlc->p_hotkeys[i].psz_action ) + 1 );
+            strcpy( psz_global_action, "global-" );
+            strcat( psz_global_action, p_libvlc->p_hotkeys[i].psz_action );
+            p_libvlc->p_hotkeys[i].psz_action = psz_global_action;
+        }
+    }
+#endif
 
     /* Initialize playlist and get commandline files */
     playlist_ThreadCreate( p_libvlc );
--- modules/gui/qt4/main_interface.hpp	Sat Aug 25 14:42:07 2007
+++ modules/gui/qt4/main_interface.hpp	Sat Aug 25 17:53:47 2007
@@ -71,6 +71,9 @@
     void closeEvent( QCloseEvent *);
     //Ui::MainInterfaceUI ui;
     friend class VolumeClickHandler;
+#if WIN32
+    virtual bool winEvent( MSG *message, long *result );
+#endif
 private:
     QSettings *settings;
     QSize mainSize, addSize;
--- modules/gui/qt4/main_interface.cpp	Sat Aug 25 14:42:07 2007
+++ modules/gui/qt4/main_interface.cpp	Sat Aug 25 17:53:47 2007
@@ -223,10 +223,115 @@
         var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf );
         vlc_object_release( p_playlist );
     }
+
+#if WIN32
+    struct libvlc_int_t::hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
+    int i;
+    UINT i_keyMod, i_vk;
+    ATOM atom;
+
+    for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
+    {
+        if( strncmp( p_hotkeys[i].psz_action, "global-key-", 11 ) ||
+                !p_hotkeys[i].i_key ) continue;
+
+        i_keyMod = 0;
+        if( p_hotkeys[i].i_key & KEY_MODIFIER_SHIFT ) i_keyMod |= MOD_SHIFT;
+        if( p_hotkeys[i].i_key & KEY_MODIFIER_ALT ) i_keyMod |= MOD_ALT;
+        if( p_hotkeys[i].i_key & KEY_MODIFIER_CTRL ) i_keyMod |= MOD_CONTROL;
+
+#define HANDLE( key ) case KEY_##key: i_vk = VK_##key; break
+#define HANDLE2( key, key2 ) case KEY_##key: i_vk = VK_##key2; break
+#ifndef VK_VOLUME_DOWN
+#define VK_VOLUME_DOWN          0xAE
+#define VK_VOLUME_UP            0xAF
+#endif
+#ifndef VK_MEDIA_NEXT_TRACK
+#define VK_MEDIA_NEXT_TRACK     0xB0
+#define VK_MEDIA_PREV_TRACK     0xB1
+#define VK_MEDIA_STOP           0xB2
+#define VK_MEDIA_PLAY_PAUSE     0xB3
+#endif
+#ifndef VK_PAGEUP
+#define VK_PAGEUP               0x21
+#define VK_PAGEDOWN             0x22
+#endif
+        i_vk = 0;
+        switch( p_hotkeys[i].i_key & ~KEY_MODIFIER )
+        {
+            HANDLE( LEFT );
+            HANDLE( RIGHT );
+            HANDLE( UP );
+            HANDLE( DOWN );
+            HANDLE( SPACE );
+            HANDLE2( ESC, ESCAPE );
+            HANDLE2( ENTER, RETURN );
+            HANDLE( F1 );
+            HANDLE( F2 );
+            HANDLE( F3 );
+            HANDLE( F4 );
+            HANDLE( F5 );
+            HANDLE( F6 );
+            HANDLE( F7 );
+            HANDLE( F8 );
+            HANDLE( F9 );
+            HANDLE( F10 );
+            HANDLE( F11 );
+            HANDLE( F12 );
+            HANDLE( PAGEUP );
+            HANDLE( PAGEDOWN );
+            HANDLE( HOME );
+            HANDLE( END );
+            HANDLE( INSERT );
+            HANDLE( DELETE );
+            HANDLE( VOLUME_DOWN );
+            HANDLE( VOLUME_UP );
+            HANDLE( MEDIA_PLAY_PAUSE );
+            HANDLE( MEDIA_STOP );
+            HANDLE( MEDIA_PREV_TRACK );
+            HANDLE( MEDIA_NEXT_TRACK );
+
+            default:
+                i_vk = p_hotkeys[i].i_key & ~KEY_MODIFIER;
+
+                /* force uppercase */
+                if( i_vk >= 'a' && i_vk <= 'z' )
+                    i_vk -= 32;
+                break;
+        }
+        if( !i_vk ) continue;
+#undef HANDLE
+#undef HANDLE2
+
+        atom = GlobalAddAtomA( p_hotkeys[i].psz_action );
+        if( !atom ) continue;
+
+        if( !RegisterHotKey( internalWinId(), atom, i_keyMod, i_vk ) )
+            GlobalDeleteAtom( atom );
+    }
+#endif
 }
 
 MainInterface::~MainInterface()
 {
+#if WIN32
+    struct libvlc_int_t::hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
+    int i;
+    ATOM atom;
+
+    for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
+    {
+        if( strncmp( p_hotkeys[i].psz_action, "global-key-", 11 ) )
+            continue;
+
+        atom = GlobalFindAtomA( p_hotkeys[i].psz_action );
+        if( !atom ) continue;
+
+        if( UnregisterHotKey( internalWinId(), atom ) )
+            GlobalDeleteAtom( atom );
+    }
+#endif
+
     /* Unregister callback for the intf-popupmenu variable */
     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
                                         VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
@@ -249,6 +354,33 @@
     p_intf->pf_release_window = NULL;
     p_intf->pf_control_window = NULL;
 }
+
+
+#if WIN32
+bool MainInterface::winEvent( MSG *message, long *result )
+{
+    if( message->message != WM_HOTKEY )
+        return( false );
+
+    struct libvlc_int_t::hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
+    int i;
+    char psz_atomName[40];
+    i = GlobalGetAtomNameA( message->wParam, psz_atomName, sizeof( psz_atomName ) );
+    if( !i ) return( false );
+
+    for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
+    {
+        if( strcmp( p_hotkeys[i].psz_action, psz_atomName ) ) continue;
+
+        var_SetInteger( p_intf->p_libvlc, "key-pressed", p_hotkeys[i].i_key );
+
+        return( true );
+    }
+
+    return( false );
+}
+#endif
+
 
 /*****************************
  *   Main UI handling        *
